Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Front Page / Sequences / Intrinsic Metafunctions / at



      typename Sequence
    , typename N
struct at
    typedef unspecified type;

      typename AssocSeq
    , typename Key
    , typename Default = unspecified
struct at
    typedef unspecified type;


at is an overloaded name:


#include <boost/mpl/at.hpp>

Model of

Tag Dispatched Metafunction


Parameter Requirement Description
Sequence Forward Sequence A sequence to be examined.
AssocSeq Associative Sequence A sequence to be examined.
N Integral Constant An offset from the beginning of the sequence specifying the element to be retrieved.
Key Any type A key for the element to be retrieved.
Default Any type A default value to return if the element is not found.

Expression semantics

For any Forward Sequence s, and Integral Constant n:

typedef at<s,n>::type t;
Return type:

A type.


0 <= n::value < size<s>::value.


Equivalent to

typedef deref< advance< begin<s>::type,n >::type >::type t;

For any Associative Sequence s, and arbitrary types key and x:

typedef at<s,key,x>::type t;
Return type:A type.
Semantics:If has_key<s,key>::value == true, t is the value type associated with key; otherwise t is identical to x.
typedef at<s,key>::type t;
Return type:

A type.


Equivalent to

typedef at<s,key,void_>::type t;


Sequence archetype Complexity
Forward Sequence Linear.
Random Access Sequence Amortized constant time.
Associative Sequence Amortized constant time.


typedef range_c<long,10,50> range;
BOOST_MPL_ASSERT_RELATION( (at< range, int_<0> >::value), ==, 10 );
BOOST_MPL_ASSERT_RELATION( (at< range, int_<10> >::value), ==, 20 );
BOOST_MPL_ASSERT_RELATION( (at< range, int_<40> >::value), ==, 50 );
typedef set< int const,long*,double > s;

BOOST_MPL_ASSERT(( is_same< at<s,char>::type, void_ > ));
BOOST_MPL_ASSERT(( is_same< at<s,int>::type, int > ));

See also

Forward Sequence, Random Access Sequence, Associative Sequence, at_c, front, back