• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
7<title>The MPL Reference Manual: inserter (class)</title>
8<link rel="stylesheet" href="../style.css" type="text/css" />
9</head>
10<body class="docframe refmanual">
11<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./front-inserter.html" class="navigation-link">Prev</a>&nbsp;<a href="./iteration-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./front-inserter.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./inserters.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
12<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a> / <a href="./inserters.html" class="navigation-link">Inserters</a> / <a href="./inserter-class.html" class="navigation-link">inserter (class)</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="inserter-class">
15<span id="id483"></span><h1><a class="toc-backref" href="./inserters.html#id1467">inserter (class)</a></h1>
16<div class="section" id="id484">
17<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
18<pre class="literal-block">
19template&lt;
20      typename State
21    , typename Operation
22    &gt;
23struct <a href="./inserter-class.html" class="identifier">inserter</a>
24{
25    typedef State state;
26    typedef Operation operation;
27};
28</pre>
29</div>
30<div class="section" id="id485">
31<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
32<p>A general-purpose model of the <a class="reference internal" href="./inserter.html">Inserter</a> concept.</p>
33</div>
34<div class="section" id="id486">
35<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
36<pre class="literal-block">
37#include &lt;<a href="../../../../boost/mpl/inserter.hpp" class="header">boost/mpl/inserter.hpp</a>&gt;
38</pre>
39</div>
40<div class="section" id="id487">
41<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
42<p><a class="reference internal" href="./inserter.html">Inserter</a></p>
43</div>
44<div class="section" id="id488">
45<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
46<table border="1" class="docutils table">
47<colgroup>
48<col width="19%" />
49<col width="38%" />
50<col width="43%" />
51</colgroup>
52<thead valign="bottom">
53<tr><th class="head">Parameter</th>
54<th class="head">Requirement</th>
55<th class="head">Description</th>
56</tr>
57</thead>
58<tbody valign="top">
59<tr><td><tt class="literal"><span class="pre">State</span></tt></td>
60<td>Any type</td>
61<td>A initial state.</td>
62</tr>
63<tr><td><tt class="literal"><span class="pre">Operation</span></tt></td>
64<td>Binary <a class="reference internal" href="./lambda-expression.html">Lambda Expression</a></td>
65<td>An output operation.</td>
66</tr>
67</tbody>
68</table>
69</div>
70<div class="section" id="id489">
71<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
72<p>The semantics of an expression are defined only
73where they differ from, or are not defined in <a class="reference internal" href="./inserter.html">Inserter</a>.</p>
74<p>For any binary <a class="reference internal" href="./lambda-expression.html">Lambda Expression</a> <tt class="literal"><span class="pre">op</span></tt> and arbitrary type <tt class="literal"><span class="pre">state</span></tt>:</p>
75<table border="1" class="docutils table">
76<colgroup>
77<col width="39%" />
78<col width="61%" />
79</colgroup>
80<thead valign="bottom">
81<tr><th class="head">Expression</th>
82<th class="head">Semantics</th>
83</tr>
84</thead>
85<tbody valign="top">
86<tr><td><tt class="literal"><span class="pre"><a href="./inserter-class.html" class="identifier">inserter</a>&lt;op,state&gt;</span></tt></td>
87<td>An <a class="reference internal" href="./inserter.html">Inserter</a>.</td>
88</tr>
89</tbody>
90</table>
91</div>
92<div class="section" id="id490">
93<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
94<p>Amortized constant time.</p>
95</div>
96<div class="section" id="id491">
97<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
98<pre class="literal-block">
99template&lt; typename N &gt; struct is_odd : <a href="./bool.html" class="identifier">bool_</a>&lt; ( N::value % 2 ) &gt; {};
100
101typedef <a href="./copy.html" class="identifier">copy</a>&lt;
102      <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt;
103    , <a href="./inserter-class.html" class="identifier">inserter</a>&lt; // a filtering '<a href="./push-back.html" class="identifier">push_back</a>' <a href="./inserter-class.html" class="identifier">inserter</a>
104          <a href="./vector.html" class="identifier">vector</a>&lt;&gt;
105        , <a href="./if.html" class="identifier">if_</a>&lt; is_odd&lt;<a href="./placeholders.html" class="identifier">_2</a>&gt;, <a href="./push-back.html" class="identifier">push_back</a>&lt;<a href="./placeholders.html" class="identifier">_1</a>,<a href="./placeholders.html" class="identifier">_2</a>&gt;, <a href="./placeholders.html" class="identifier">_1</a> &gt;
106        &gt;
107    &gt;::type odds;
108
109<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( <a href="./equal.html" class="identifier">equal</a>&lt; odds, <a href="./vector-c.html" class="identifier">vector_c</a>&lt;int,1,3,5,7,9&gt;, <a href="./equal-to.html" class="identifier">equal_to</a>&lt;_,_&gt; > ));
110</pre>
111</div>
112<div class="section" id="id492">
113<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
114<p><a class="reference internal" href="./algorithms.html">Algorithms</a>, <a class="reference internal" href="./inserter.html">Inserter</a>, <a class="reference internal" href="./reversible-algorithm.html">Reversible Algorithm</a>, <a class="reference internal" href="./front-inserter.html">front_inserter</a>, <a class="reference internal" href="./back-inserter.html">back_inserter</a></p>
115</div>
116</div>
117
118<div class="footer-separator"></div>
119<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./front-inserter.html" class="navigation-link">Prev</a>&nbsp;<a href="./iteration-algorithms.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./front-inserter.html" class="navigation-link">Back</a>&nbsp;Along</span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./inserters.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
120<td><div class="copyright-footer"><div class="copyright">Copyright ©  2001-2009 Aleksey Gurtovoy and David Abrahams</div>
121Distributed under the Boost Software License, Version 1.0. (See accompanying
122file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
123</html>
124