[Home]at_c

Synopsis

template<
      long n
    , typename Sequence
    >
struct at_c
{
    typedef unspecified type;
};

Description

Returns a type identical to the n-th element from the beginning of the sequence. at_c<n,Sequence>::type is a shorcut notation for at< integral_c<long,n>, Sequence>::type.

Definition

#include "boost/mpl/at.hpp"

Parameters

 Parameter  Requirement  Description  
nAn compile-time integral constantAn offset from the beginning of the sequence that specifies the element to be retrieved.
SequenceA model of Forward SequenceA sequence being examined.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef at_c<n,Sequence>::type t;A type0 <= n < size<Sequence>::type::valueEquivalent to typedef at< integral_c<long,n>, Sequence>::type t;

Complexity

Depends on the implementation of the particular sequence it is applied to. Linear in the worst case, or amortized constant time.

Example

typedef range_c<long,10,50> range;
BOOST_STATIC_ASSERT(at_c<0,range>::type::value == 10);
BOOST_STATIC_ASSERT(at_c<10,range>::type::value == 20);
BOOST_STATIC_ASSERT(at_c<40,range>::type::value == 50);

See also

Forward Sequence, at, front, back


Table of Content | Reference
Last edited July 17, 2002 3:50 am