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 the documentation for an old version of Boost. Click here to view this page for the latest version.
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]

Header

#include <boost/mpl/reverse.hpp>

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<s,in>::type r; 
Return type:A type.
Semantics:

Equivalent to

typedef reverse_copy<s,in>::type r; 

Complexity

Linear.

Example

typedef vector_c<int,9,8,7,6,5,4,3,2,1,0> numbers;
typedef reverse< numbers >::type result;

BOOST_MPL_ASSERT(( equal< result, range_c<int,0,10> > ));

See also

Transformation Algorithms, Reversible Algorithm, reverse_copy, copy, copy_if