Back to Arangodb

The MPL Reference Manual: at

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/at.html

3.12.9.14.4 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Sequences / Intrinsic Metafunctions / at |

at

Synopsis

template<
      typename Sequence
    , typename N
    >
struct[at](./at.html){
    typedef_unspecified_type;
};

template<
      typename AssocSeq
    , typename Key
    , typename Default =_unspecified_>
struct[at](./at.html){
    typedef_unspecified_type;
};

Description

at is an overloaded name:

  • at<Sequence,N> returns the N-th element from the beginning of the Forward Sequence Sequence.
  • at<AssocSeq,Key,Default> returns the first element associated with Key in the Associative Sequence AssocSeq, or Default if no such element exists.
#include <[boost/mpl/at.hpp](../../../../boost/mpl/at.hpp)>

Model of

Tag Dispatched Metafunction

Parameters

ParameterRequirementDescription
SequenceForward SequenceA sequence to be examined.
AssocSeqAssociative SequenceA sequence to be examined.
NIntegral ConstantAn offset from the beginning of the sequence specifying the element to be retrieved.
KeyAny typeA key for the element to be retrieved.
DefaultAny typeA default value to return if the element is not found.

Expression semantics

For any Forward Sequence s, and Integral Constant n:

typedef[at](./at.html)<s,n>::type t;

| Return type: |

A type.

| | Precondition: |

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

| | Semantics: |

Equivalent to

typedef[deref](./deref.html)<[advance](./advance.html)<[begin](./begin.html)<s>::type,n >::type >::type t;

|

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

typedef[at](./at.html)<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](./at.html)<s,key>::type t;

| Return type: |

A type.

| | Semantics: |

Equivalent to

typedef[at](./at.html)<s,key,[void\_](./void.html)>::type t;

|

Complexity

Sequence archetypeComplexity
Forward SequenceLinear.
Random Access SequenceAmortized constant time.
Associative SequenceAmortized constant time.

Example

typedef[range\_c](./range-c.html)<long,10,50> range;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([at](./at.html)< range,[int\_](./int.html)<0> >::value), ==, 10 );[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([at](./at.html)< range,[int\_](./int.html)<10> >::value), ==, 20 );[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([at](./at.html)< range,[int\_](./int.html)<40> >::value), ==, 50 );
typedef[set](./set.html)< int const,long*,double > s;[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<[at](./at.html)<s,char>::type,[void\_](./void.html)> ));[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<[at](./at.html)<s,int>::type, int > ));

See also

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

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |