mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 08:52:21 +01:00
62 lines
3.6 KiB
HTML
62 lines
3.6 KiB
HTML
<!doctype html public "-//ietf//dtd html//en">
|
|
<html><head><title>boost::mpl::insert</title>
|
|
<link rel="stylesheet" href="../mpl_wiki.css">
|
|
</head><body bgcolor="white">
|
|
<h1><a href="../Table_of_Contents.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>insert</h1><h3>Synopsis</h3>
|
|
<p>
|
|
<pre>
|
|
template<
|
|
typename Sequence
|
|
, typename Pos
|
|
, typename T
|
|
>
|
|
struct insert
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
</pre>
|
|
<p>
|
|
<h3>Description</h3>
|
|
<p>
|
|
<code>insert</code> performs an insertion of type <code>T</code> at an arbitrary position in the sequence. The algorithm returns a new sequence which contains all the elements from <code>Sequence</code> plus the type <code>T</code> at the <code>distance< begin<Sequence>::type,Pos >::type</code> position from the beginning. The result sequence preserves all the functional and performance characteristics of the original <code>Sequence</code>, except its size and identity.
|
|
<p>
|
|
<h3>Definition</h3>
|
|
<p>
|
|
<pre>
|
|
#include "<a href="../../../../../boost/mpl/insert.hpp">boost/mpl/insert.hpp</a>"
|
|
</pre>
|
|
<p>
|
|
<h3>Parameters</h3>
|
|
<table border="1">
|
|
<tr><th> Parameter </th><th> Requirement </th><th> Description </th></tr>
|
|
<tr><td><code>Sequence</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td>A sequence to handle the insert operation. </td></tr>
|
|
<tr><td><code>Pos</code></td><td>A model of <a href="../Forward_Iterator.html">Forward Iterator</a></td><td>An insert position in the <code>Sequence</code>. </td></tr>
|
|
<tr><td><code>T</code></td><td>A type</td><td>The element to be inserted. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Expression semantics</h3>
|
|
<p>
|
|
<table border="1">
|
|
<tr><th> Expression </th><th> Expression type </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
|
<tr><td><code>typedef insert<Sequence,pos,T>::type s;</code></td><td>A model of <a href="../Extensible_Sequence.html">Extensible Sequence</a></td><td><code>pos</code> is a valid iterator in <code>Sequence</code>.</td><td><code>s</code> contains <code>T</code> at the <code>distance< begin<Sequence>::type,pos >::type</code> position.</td><td><code>size<s>::type::value == size<Sequence>::type::value + 1</code>; <code>at< distance< begin<Sequence>::type,pos >::type, s >::type</code> is identical to <code>T</code>; the relative order of the elements in <code>s</code> is the same as in <code>Sequence</code>. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Complexity</h3>
|
|
<p>
|
|
Sequence dependent. Linear in the worst case, or amortized constant time.
|
|
<p>
|
|
<h3>Example</h3>
|
|
<p>
|
|
<pre>
|
|
typedef <a href="../Reference/list_c.html">list_c</a><int,0,1,3,4,5,6,7,8,9> numbers;
|
|
typedef <a href="../Reference/find.html">find</a>< numbers,integral_c<int,3> >::type pos;
|
|
typedef insert< numbers,pos,integral_c<int,2> >::type range;
|
|
BOOST_STATIC_ASSERT(<a href="../Reference/size.html">size</a><range>::type::value == 10);
|
|
BOOST_STATIC_ASSERT((<a href="../Reference/equal.html">equal</a>< range,<a href="../Reference/range_c.html">range_c</a><int,0,10> >::type::value));
|
|
</pre>
|
|
<p>
|
|
<h3>See also</h3>
|
|
<p>
|
|
<a href="../Extensible_Sequence.html">Extensible Sequence</a>, <code><a href="../Reference/insert_range.html">insert_range</a></code>, <code><a href="../Reference/push_front.html">push_front</a></code>, <code><a href="../Reference/push_back.html">push_back</a></code>, <code><a href="../Reference/erase.html">erase</a></code>
|
|
<p><hr>
|
|
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited July 17, 2002 5:17 am</body></html> |