# copy_backward

### Synopsis

    template<
          typename Sequence
        , typename State
        , typename BinaryOp
        >
    struct copy_backward
    {
        typedef unspecified type;
    };

### Description

`copy_backward` is, in fact, just another name for `fold_backward`. It was introduced for symmetry with `copy_backward_if` [1], and because it's a nice name for one of the typical `fold_backward` applications, that is, copying the content of one sequence into another - see the example below.

### Definition

    #include "boost/mpl/copy_backward.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | A model of Sequence | A sequence to iterate.
`State` | A type | The initial state for the first `BinaryOp` application.
`BinaryOp` | A model of [Lambda Function] | The operation to be executed on backward traversal.

### Expression semantics

Expression | Expression type | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typedef copy_backward<Sequence,T,Op>::type s;` | A type |  | Equivalent to `typedef fold_backward< Sequence,T,Op >::type s;`. |

### Complexity

Linear. Exactly `size<Sequence>::type::value` applications of `BinaryOp`.

### Example

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

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

### Notes

[1] In case if you wonder why `copy_backward_if`, in its turn, wasn't just called `fold_backward_if`, - something that would allow to eliminate the family of `copy_backward` algorithms completely - these two have quite different semantics.

### See also

Algorithms, `copy_backward_if`, `copy`, `copy_if`, `fold`, `fold_backward`

Table of Content | Reference
Last edited July 19, 2002 2:11 am