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 / Inserters / back_inserter

back_inserter

Synopsis

template<
      typename Seq
    >
struct back_inserter
{
    // unspecified
    // ...
};

Description

Inserts elements at the end of the sequence.

Header

#include <boost/mpl/back_inserter.hpp>

Model of

Inserter

Parameters

Parameter Requirement Description
Seq Back Extensible Sequence A sequence to bind the inserter to.

Expression semantics

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

For any Back Extensible Sequence s:

Expression Semantics
back_inserter<s>

An Inserter in, equivalent to

struct in : inserter<s,push_back<_1,_2> > {};

Complexity

Amortized constant time.

Example

typedef copy<
      range_c<int,5,10>
    , back_inserter< vector_c<int,0,1,2,3,4> >
    >::type range;
   
BOOST_MPL_ASSERT(( equal< range, range_c<int,0,10> > ));

See also

Algorithms, Inserter, Reversible Algorithm, inserter, front_inserter, push_back