• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. Range 2.0">
8<link rel="up" href="../new.html" title="New algorithms">
9<link rel="prev" href="for_each.html" title="for_each">
10<link rel="next" href="iota.html" title="iota">
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="for_each.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.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="iota.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="range.reference.algorithms.new.insert"></a><a class="link" href="insert.html" title="insert">insert</a>
28</h5></div></div></div>
29<h6>
30<a name="range.reference.algorithms.new.insert.h0"></a>
31            <span class="phrase"><a name="range.reference.algorithms.new.insert.prototype"></a></span><a class="link" href="insert.html#range.reference.algorithms.new.insert.prototype">Prototype</a>
32          </h6>
33<p>
34</p>
35<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
36    <span class="keyword">class</span> <span class="identifier">Container</span><span class="special">,</span>
37    <span class="keyword">class</span> <span class="identifier">SinglePassRange</span>
38<span class="special">&gt;</span>
39<span class="identifier">Container</span><span class="special">&amp;</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">Container</span><span class="special">&amp;</span> <span class="identifier">target</span><span class="special">,</span>
40                  <span class="keyword">typename</span> <span class="identifier">Container</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">before</span><span class="special">,</span>
41                  <span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">from</span><span class="special">);</span>
42
43<span class="comment">// This overload is for target containers that do not require an insertion</span>
44<span class="comment">// position e.g. set/map</span>
45<span class="keyword">template</span><span class="special">&lt;</span>
46    <span class="keyword">class</span> <span class="identifier">Container</span><span class="special">,</span>
47    <span class="keyword">class</span> <span class="identifier">SinglePassRange</span>
48<span class="special">&gt;</span>
49<span class="identifier">Container</span><span class="special">&amp;</span> <span class="identifier">insert</span><span class="special">(</span><span class="identifier">Container</span><span class="special">&amp;</span> <span class="identifier">target</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">from</span><span class="special">);</span>
50</pre>
51<p>
52          </p>
53<h6>
54<a name="range.reference.algorithms.new.insert.h1"></a>
55            <span class="phrase"><a name="range.reference.algorithms.new.insert.description"></a></span><a class="link" href="insert.html#range.reference.algorithms.new.insert.description">Description</a>
56          </h6>
57<p>
58            <code class="computeroutput"><span class="identifier">insert</span></code> all of the elements
59            in the range <code class="computeroutput"><span class="identifier">from</span></code> before
60            the <code class="computeroutput"><span class="identifier">before</span></code> iterator into
61            <code class="computeroutput"><span class="identifier">target</span></code>.
62          </p>
63<h6>
64<a name="range.reference.algorithms.new.insert.h2"></a>
65            <span class="phrase"><a name="range.reference.algorithms.new.insert.definition"></a></span><a class="link" href="insert.html#range.reference.algorithms.new.insert.definition">Definition</a>
66          </h6>
67<p>
68            Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm_ext</span><span class="special">/</span><span class="identifier">insert</span><span class="special">.</span><span class="identifier">hpp</span></code>
69          </p>
70<h6>
71<a name="range.reference.algorithms.new.insert.h3"></a>
72            <span class="phrase"><a name="range.reference.algorithms.new.insert.requirements"></a></span><a class="link" href="insert.html#range.reference.algorithms.new.insert.requirements">Requirements</a>
73          </h6>
74<div class="orderedlist"><ol class="orderedlist" type="1">
75<li class="listitem">
76                <code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
77                a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
78                Pass Range</a> Concept.
79              </li>
80<li class="listitem">
81                <code class="computeroutput"><span class="identifier">Container</span></code> supports
82                insert at a specified position.
83              </li>
84<li class="listitem">
85                <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>'s
86                value type is convertible to <code class="computeroutput"><span class="identifier">Container</span></code>'s
87                value type.
88              </li>
89</ol></div>
90<h6>
91<a name="range.reference.algorithms.new.insert.h4"></a>
92            <span class="phrase"><a name="range.reference.algorithms.new.insert.complexity"></a></span><a class="link" href="insert.html#range.reference.algorithms.new.insert.complexity">Complexity</a>
93          </h6>
94<p>
95            Linear. <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">from</span><span class="special">)</span></code>
96            assignments are performed.
97          </p>
98</div>
99<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
100<td align="left"></td>
101<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
102      Neil Groves<p>
103        Distributed under the Boost Software License, Version 1.0. (See accompanying
104        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>)
105      </p>
106</div></td>
107</tr></table>
108<hr>
109<div class="spirit-nav">
110<a accesskey="p" href="for_each.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../new.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="iota.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
111</div>
112</body>
113</html>
114