...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Sequences / Intrinsic Metafunctions / insert |
template< typename Sequence , typename Pos , typename T > struct insert { typedef unspecified type; }; template< typename Sequence , typename T > struct insert { typedef unspecified type; };
insert is an overloaded name:
#include <boost/mpl/insert.hpp>
Parameter | Requirement | Description |
---|---|---|
Sequence | Extensible Sequence or Extensible Associative Sequence | A sequence to insert into. |
Pos | Forward Iterator | An iterator in Sequence specifying the insertion position. |
T | Any type | The element to be inserted. |
For any Extensible Sequence s, iterator pos in s, and arbitrary type x:
typedef insert::type r;
Return type: | Extensible Sequence |
---|---|
Precondition: | pos is an iterator in s. |
Semantics: | r is a sequence, concept-identical to s, of the following elements:
[begin |
Postcondition: | The relative order of the elements in r is the same as in s. at< r, distance< begin is identical to x; size |
For any Extensible Associative Sequence s, iterator pos in s, and arbitrary type x:
typedef insert::type r;
Return type: | Extensible Associative Sequence |
---|---|
Semantics: | r is concept-identical and equivalent to s, except that
at< r, key_type |
Postcondition: | size |
typedef insert::type r;
Return type: | Extensible Associative Sequence |
---|---|
Precondition: | pos is an iterator in s. |
Semantics: | Equivalent to typedef insert |
Sequence archetype | Complexity |
---|---|
Extensible Associative Sequence | Amortized constant time. |
Extensible Sequence | Linear in the worst case, or amortized constant time. |
typedef vector_cnumbers; typedef find< numbers,integral_c >::type pos; typedef insert< numbers,pos,integral_c >::type range; BOOST_MPL_ASSERT_RELATION( size ::value, ==, 10 ); BOOST_MPL_ASSERT(( equal< range,range_c > ));
typedef map< mpl::pair> m; typedef insert pair >::type m1; BOOST_MPL_ASSERT_RELATION( size ::value, ==, 2 ); BOOST_MPL_ASSERT(( is_same< at ::type,unsigned > )); BOOST_MPL_ASSERT(( is_same< at ::type,long > ));