Back to Arangodb

insert

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/insert.html

3.12.9.15.5 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Sequences / Intrinsic Metafunctions / insert |

insert

Synopsis

template<
      typename Sequence
    , typename Pos
    , typename T
    >
struct[insert](./insert.html){
    typedef_unspecified_type;
};

template<
      typename Sequence
    , typename T
    >
struct[insert](./insert.html){
    typedef_unspecified_type;
};

Description

insert is an overloaded name:

#include <[boost/mpl/insert.hpp](../../../../boost/mpl/insert.hpp)>

Model of

Tag Dispatched Metafunction

Parameters

ParameterRequirementDescription
SequenceExtensible Sequence or Extensible Associative SequenceA sequence to insert into.
PosForward IteratorAn iterator in Sequence specifying the insertion position.
TAny typeThe element to be inserted.

Expression semantics

For any Extensible Sequence s, iterator pos in s, and arbitrary type x:

typedef[insert](./insert.html)<s,pos,x>::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<s>::type, pos), x, [pos, end<s>::type).

| | Postcondition: |

The relative order of the elements in r is the same as in s.

[at](./at.html)< r,[distance](./distance.html)<[begin](./begin.html)<s>::type,pos >::type >::type

is identical to x;

[size](./size.html)<r>::value ==[size](./size.html)<s>::value + 1;

|

For any Extensible Associative Sequence s, iterator pos in s, and arbitrary type x:

typedef[insert](./insert.html)<s,x>::type r;

| Return type: | Extensible Associative Sequence | | Semantics: | r is concept-identical and equivalent to s, except that at< r, key_type<s,x>::type >::type is identical to value_type<s,x>::type. | | Postcondition: | size<r>::value == size<s>::value + 1. |

typedef[insert](./insert.html)<s,pos,x>::type r;

| Return type: | Extensible Associative Sequence | | Precondition: | pos is an iterator in s. | | Semantics: | Equivalent to typedef insert<s,x>::type r; pos is ignored. |

Complexity

Sequence archetypeComplexity
Extensible Associative SequenceAmortized constant time.
Extensible SequenceLinear in the worst case, or amortized constant time.

Example

typedef[vector\_c](./vector-c.html)<int,0,1,3,4,5,6,7,8,9> numbers;
typedef[find](./find.html)< numbers,[integral\_c](./integral-c.html)<int,3> >::type pos;
typedef[insert](./insert.html)< numbers,pos,[integral\_c](./integral-c.html)<int,2> >::type range;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([size](./size.html)<range>::value, ==, 10 );[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)< range,[range\_c](./range-c.html)<int,0,10> > ));
typedef[map](./map.html)< mpl::[pair](./pair.html)<int,unsigned> > m;
typedef[insert](./insert.html)<m,mpl::[pair](./pair.html)<char,long> >::type m1;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([size](./size.html)<m1>::value, ==, 2 );[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<[at](./at.html)<m1,int>::type,unsigned > ));[BOOST\_MPL\_ASSERT](./assert.html)(( is_same<[at](./at.html)<m1,char>::type,long > ));

See also

Extensible Sequence, Extensible Associative Sequence, insert_range, push_front, push_back, erase

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |