1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>insert</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.2"> 8<link rel="up" href="../functions.html" title="Functions"> 9<link rel="prev" href="erase_key.html" title="erase_key"> 10<link rel="next" href="insert_range.html" title="insert_range"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="erase_key.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="insert_range.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="fusion.algorithm.transformation.functions.insert"></a><a class="link" href="insert.html" title="insert">insert</a> 28</h5></div></div></div> 29<h6> 30<a name="fusion.algorithm.transformation.functions.insert.h0"></a> 31 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.description"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.description">Description</a> 32 </h6> 33<p> 34 Returns a new sequence with all the elements of the original, an a new 35 element inserted the position described by a given iterator. 36 </p> 37<h6> 38<a name="fusion.algorithm.transformation.functions.insert.h1"></a> 39 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.synopsis"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.synopsis">Synopsis</a> 40 </h6> 41<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 42 <span class="keyword">typename</span> <span class="identifier">Sequence</span><span class="special">,</span> 43 <span class="keyword">typename</span> <span class="identifier">Pos</span><span class="special">,</span> 44 <span class="keyword">typename</span> <span class="identifier">T</span> 45 <span class="special">></span> 46<span class="keyword">typename</span> <a class="link" href="../metafunctions/insert.html" title="insert"><code class="computeroutput"><span class="identifier">result_of</span><span class="special">::</span><span class="identifier">insert</span></code></a><span class="special"><</span><span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">,</span> <span class="identifier">Pos</span><span class="special">,</span> <span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">insert</span><span class="special">(</span> 47 <span class="identifier">Sequence</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">seq</span><span class="special">,</span> <span class="identifier">Pos</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">pos</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">t</span><span class="special">);</span> 48</pre> 49<div class="table"> 50<a name="fusion.algorithm.transformation.functions.insert.t0"></a><p class="title"><b>Table 1.78. Parameters</b></p> 51<div class="table-contents"><table class="table" summary="Parameters"> 52<colgroup> 53<col> 54<col> 55<col> 56</colgroup> 57<thead><tr> 58<th> 59 <p> 60 Parameter 61 </p> 62 </th> 63<th> 64 <p> 65 Requirement 66 </p> 67 </th> 68<th> 69 <p> 70 Description 71 </p> 72 </th> 73</tr></thead> 74<tbody> 75<tr> 76<td> 77 <p> 78 <code class="computeroutput"><span class="identifier">seq</span></code> 79 </p> 80 </td> 81<td> 82 <p> 83 A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward 84 Sequence</a> 85 </p> 86 </td> 87<td> 88 <p> 89 Operation's argument 90 </p> 91 </td> 92</tr> 93<tr> 94<td> 95 <p> 96 <code class="computeroutput"><span class="identifier">pos</span></code> 97 </p> 98 </td> 99<td> 100 <p> 101 A model of <a class="link" href="../../../iterator/concepts/forward_iterator.html" title="Forward Iterator">Forward 102 Iterator</a> 103 </p> 104 </td> 105<td> 106 <p> 107 The position to insert at 108 </p> 109 </td> 110</tr> 111<tr> 112<td> 113 <p> 114 <code class="computeroutput"><span class="identifier">t</span></code> 115 </p> 116 </td> 117<td> 118 <p> 119 Any type 120 </p> 121 </td> 122<td> 123 <p> 124 The value to insert 125 </p> 126 </td> 127</tr> 128</tbody> 129</table></div> 130</div> 131<br class="table-break"><h6> 132<a name="fusion.algorithm.transformation.functions.insert.h2"></a> 133 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.expression_semantics"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.expression_semantics">Expression 134 Semantics</a> 135 </h6> 136<pre class="programlisting"><a class="link" href="insert.html" title="insert"><code class="computeroutput"><span class="identifier">insert</span></code></a><span class="special">(</span><span class="identifier">seq</span><span class="special">,</span> <span class="identifier">pos</span><span class="special">,</span> <span class="identifier">t</span><span class="special">);</span> 137</pre> 138<p> 139 <span class="bold"><strong>Return type</strong></span>: 140 </p> 141<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 142 A model of <a class="link" href="../../../sequence/concepts/forward_sequence.html" title="Forward Sequence">Forward 143 Sequence</a>. 144 </li></ul></div> 145<p> 146 <span class="bold"><strong>Semantics</strong></span>: Returns a new sequence, containing 147 all the elements of <code class="computeroutput"><span class="identifier">seq</span></code>, 148 in their original order, and a new element with the type and value of 149 <code class="computeroutput"><span class="identifier">t</span></code> inserted at iterator 150 <code class="computeroutput"><span class="identifier">pos</span></code>. 151 </p> 152<h6> 153<a name="fusion.algorithm.transformation.functions.insert.h3"></a> 154 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.complexity"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.complexity">Complexity</a> 155 </h6> 156<p> 157 Constant. Returns a view which is lazily evaluated. 158 </p> 159<h6> 160<a name="fusion.algorithm.transformation.functions.insert.h4"></a> 161 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.header"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.header">Header</a> 162 </h6> 163<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">transformation</span><span class="special">/</span><span class="identifier">insert</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 164<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">insert</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 165</pre> 166<h6> 167<a name="fusion.algorithm.transformation.functions.insert.h5"></a> 168 <span class="phrase"><a name="fusion.algorithm.transformation.functions.insert.example"></a></span><a class="link" href="insert.html#fusion.algorithm.transformation.functions.insert.example">Example</a> 169 </h6> 170<pre class="programlisting"><span class="keyword">const</span> <a class="link" href="../../../container/vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">int</span><span class="special">></span> <span class="identifier">vec</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">);</span> 171<span class="identifier">assert</span><span class="special">(</span><a class="link" href="insert.html" title="insert"><code class="computeroutput"><span class="identifier">insert</span></code></a><span class="special">(</span><span class="identifier">vec</span><span class="special">,</span> <a class="link" href="../../../iterator/functions/next.html" title="next"><code class="computeroutput"><span class="identifier">next</span></code></a><span class="special">(</span><a class="link" href="../../../sequence/intrinsic/functions/begin.html" title="begin"><code class="computeroutput"><span class="identifier">begin</span></code></a><span class="special">(</span><span class="identifier">vec</span><span class="special">)),</span> <span class="number">3</span><span class="special">)</span> <span class="special">==</span> <a class="link" href="../../../container/generation/functions/make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></a><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">2</span><span class="special">));</span> 172</pre> 173</div> 174<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 175<td align="left"></td> 176<td align="right"><div class="copyright-footer">Copyright © 2001-2006, 2011, 2012 Joel de Guzman, 177 Dan Marsden, Tobias Schwinger<p> 178 Distributed under the Boost Software License, Version 1.0. (See accompanying 179 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 180 </p> 181</div></td> 182</tr></table> 183<hr> 184<div class="spirit-nav"> 185<a accesskey="p" href="erase_key.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="insert_range.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 186</div> 187</body> 188</html> 189