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

The MPL Reference Manual: back
Front Page / Sequences / Intrinsic Metafunctions / back

back

Synopsis

template<
      typename Sequence
    >
struct back
{
    typedef unspecified type;
};

Description

Returns the last element in the sequence.

Parameters

Parameter Requirement Description
Sequence Bidirectional Sequence A sequence to be examined.

Expression semantics

For any Bidirectional Sequence s:

typedef back::type t;
Return type:

A type.

Precondition:

empty::value == false.

Semantics:

Equivalent to

typedef deref< prior< end::type >::type >::type t;

Complexity

Amortized constant time.

Example

typedef range_c range1;
typedef range_c range2;
typedef range_c range3;

BOOST_MPL_ASSERT_RELATION( back::value, ==, 0 );
BOOST_MPL_ASSERT_RELATION( back::value, ==, 9 );
BOOST_MPL_ASSERT_RELATION( back::value, ==, -1 );