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 Pos
    , typename Range
struct insert_range
    typedef unspecified type;


insert_range performs an insertion of a range of elements at an arbitrary position in the sequence. The algorithm returns a new sequence which contains all the elements of Sequence plus all the elements of Range starting at the distance< begin<Sequence>::type,Pos >::type position from the beginning. The result sequence preserves all the functional and performance characteristics of the original Sequence, except its size and identity.


#include "boost/mpl/insert_range.hpp"


 Parameter  Requirement  Description  
SequenceA model of Extensible SequenceA sequence to handle the insert operation.
PosA model of Forward IteratorAn insert position in the Sequence.
RangeA model of SequenceThe range of elements to be inserted.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition  
typedef insert<Sequence,pos,range>::type s;A model of Extensible Sequencepos is a valid iterator in Sequence.s contains all the elements from range starting at the distance< begin<Sequence>::type,pos >::type position.size<s>::type::value == size<Sequence>::type::value + size<range>::type::value; the relative order of the elements in s is the same as in Sequence.


Linear time.


typedef list_c<int,0,1,7,8,9> numbers;
typedef find< numbers,integral_c<int,7> >::type pos;
typedef insert_range< numbers,pos,range_c<int,2,7> >::type range;
BOOST_STATIC_ASSERT(size<range>::type::value == 10);
BOOST_STATIC_ASSERT((equal< range,range_c<int,0,10> >::type::value));

See also

Extensible Sequence, insert, push_front, push_back, erase

Table of Contents
Last edited July 22, 2002 4:32 pm