Boost C++ Libraries

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

This is an old version of boost. Click here for the latest version's documentation home page.

[Home]at_c

Synopsis

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

Description

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

Definition

#include "boost/mpl/at.hpp"

Parameters

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

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef at_c<Sequence,n>::type t;A type0 <= n < size<Sequence>::type::valueEquivalent to typedef at< Sequence, integral_c<long,n> >::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<range,0>::type::value == 10);
BOOST_STATIC_ASSERT(at_c<range,10>::type::value == 20);
BOOST_STATIC_ASSERT(at_c<range,40>::type::value == 50);

See also

Forward Sequence, at, front, back


Table of Contents
Last edited October 21, 2002 4:09 am