Front Page / Algorithms / Transformation Algorithms / reverse_copy

# reverse_copy

### Synopsis

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

### Description

Returns a reversed copy of the original sequence.

[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/copy.hpp>

### Model of

Reversible Algorithm

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | Forward Sequence | A sequence to copy.
`In` | Inserter | An inserter.

### Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Reversible Algorithm.

For any Forward Sequence `s`, and an Inserter `in`:

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

Return type: | A type.

Semantics:

Equivalent to

    typedef reverse_fold< s,in::state,in::operation >::type r;

### Complexity

Linear. Exactly `size<s>::value` applications of `in::operation`.

### Example

    typedef list_c<int,10,11,12,13,14,15,16,17,18,19>::type numbers;
    typedef reverse_copy<
          range_c<int,0,10>
        , front_inserter< numbers >
        >::type result;

    BOOST_MPL_ASSERT_RELATION( size<result>::value, ==, 20 );
    BOOST_MPL_ASSERT(( equal< result,range_c<int,0,20> > ));

### See also

Transformation Algorithms, Reversible Algorithm, copy, reverse_copy_if, reverse_transform