insert_range
template<
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 |
|---|---|---|
Sequence | A model of Extensible Sequence | A sequence to handle the insert operation. |
Pos | A model of Forward Iterator | An insert position in the Sequence. |
Range | A model of Sequence | The range of elements to be inserted. |
| Expression | Expression type | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
typedef insert<Sequence,pos,range>::type s; | A model of Extensible Sequence | pos 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));
Extensible Sequence, insert, push_front, push_back, erase