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: reverse
Front Page / Algorithms / Transformation Algorithms / reverse

reverse

Synopsis

template<
      typename Sequence
    , typename In = unspecified
    >
struct reverse
{
    typedef unspecified type;
};

Description

Returns a reversed copy of the original sequence. reverse is a synonym for reverse_copy.

[Note: This wording applies to a no-inserter version(s) of the algorithm. See the Expression semantics subsection for a precise specification of the algorithm's details in all cases — end note]

Parameters

Parameter Requirement Description
Sequence Forward Sequence A sequence to reverse.
In Inserter An inserter.

Expression semantics

For any Forward Sequence s, and an Inserter in:

typedef reverse::type r;
Return type:

A type.

Semantics:

Equivalent to

typedef reverse_copy::type r;

Complexity

Linear.

Example

typedef vector_c numbers;
typedef reverse< numbers >::type result;

BOOST_MPL_ASSERT(( equal< result, range_c > ));