Boost C++ Libraries 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 for the latest Boost documentation.



      typename Sequence
    , typename State
    , typename BinaryOp
struct copy_backward
    typedef unspecified type;


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.


#include "boost/mpl/copy_backward.hpp"


 Parameter  Requirement  Description  
SequenceA model of SequenceA sequence to iterate.
StateA typeThe initial state for the first BinaryOp application.
BinaryOpA 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 typeEquivalent to typedef fold_backward< Sequence,T,Op >::type s;.


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


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

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


[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 Contents
Last edited July 19, 2002 2:11 am