Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/doc/refmanual/inserter.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 7.3 KB
Line 
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.3.6: http://docutils.sourceforge.net/" />
7<title>The MPL Reference Manual: Inserter</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="./algorithms-concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./reversible-algorithm.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./reversible-algorithm.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms-concepts.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="./algorithms-concepts.html" class="navigation-link">Concepts</a> / <a href="./inserter.html" class="navigation-link">Inserter</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="inserter">
15<h1><a class="toc-backref" href="./algorithms-concepts.html#id390" name="inserter">Inserter</a></h1>
16<div class="section" id="inserter-description">
17<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
18<p>An <a class="reference" href="./inserter.html">Inserter</a> is a compile-time substitute for STL <a class="reference" href="http://www.sgi.com/tech/stl/OutputIterator.html" target="_top">Output Iterator</a>.
19Under the hood, it's simply a type holding
20two entities: a <em>state</em> and an <em>operation</em>. When passed to a
21<a class="reference" href="./transformation-algorithms.html">transformation algorithm</a>, the inserter's binary operation is
22invoked for every element that would normally be written into the
23output iterator, with the element itself (as the second
24argument) and the result of the previous operation's invocation — or,
25for the very first element, the inserter's initial state.</p>
26<p>Technically, instead of taking a single inserter parameter,
27<a class="reference" href="./transformation-algorithms.html">transformation algorithms</a> could accept the state and the &quot;output&quot;
28operation separately. Grouping these in a single parameter entity,
29however, brings the algorithms semantically and syntactically closer to
30their STL counterparts, significantly simplifying many of the common
31use cases.</p>
32</div>
33<div class="section" id="valid-expressions">
34<h3><a class="subsection-title" href="#valid-expressions" name="valid-expressions">Valid expressions</a></h3>
35<p>In the following table and subsequent specifications, <tt class="literal"><span class="pre">in</span></tt> is a model of <a class="reference" href="./inserter.html">Inserter</a>.</p>
36<table border="1" class="table">
37<colgroup>
38<col width="43%" />
39<col width="57%" />
40</colgroup>
41<thead valign="bottom">
42<tr><th>Expression</th>
43<th>Type</th>
44</tr>
45</thead>
46<tbody valign="top">
47<tr><td><tt class="literal"><span class="pre">in::state</span></tt></td>
48<td>Any type</td>
49</tr>
50<tr><td><tt class="literal"><span class="pre">in::operation</span></tt></td>
51<td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td>
52</tr>
53</tbody>
54</table>
55</div>
56<div class="section" id="inserter-expression-semantics">
57<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
58<table border="1" class="table">
59<colgroup>
60<col width="35%" />
61<col width="65%" />
62</colgroup>
63<thead valign="bottom">
64<tr><th>Expression</th>
65<th>Semantics</th>
66</tr>
67</thead>
68<tbody valign="top">
69<tr><td><tt class="literal"><span class="pre">in::state</span></tt></td>
70<td>The inserter's initial state.</td>
71</tr>
72<tr><td><tt class="literal"><span class="pre">in::operation</span></tt></td>
73<td>The inserter's &quot;output&quot; operation.</td>
74</tr>
75</tbody>
76</table>
77</div>
78<div class="section" id="inserter-example">
79<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
80<pre class="literal-block">
81typedef <a href="./transform.html" class="identifier">transform</a>&lt;
82      <a href="./range-c.html" class="identifier">range_c</a>&lt;int,0,10&gt;
83    , <a href="./plus.html" class="identifier">plus</a>&lt;_1,_1&gt;
84    , <a href="./back-inserter.html" class="identifier">back_inserter</a>&lt; vector0&lt;&gt; &gt;
85    &gt;::type result;
86</pre>
87</div>
88<div class="section" id="inserter-models">
89<h3><a class="subsection-title" href="#models" name="models">Models</a></h3>
90<ul class="simple">
91<li><a class="refentry reference" href="./inserters-inserter.html"><tt class="refentry literal"><span class="pre">inserter</span></tt></a></li>
92<li><a class="refentry reference" href="./front-inserter.html"><tt class="refentry literal"><span class="pre">front_inserter</span></tt></a></li>
93<li><a class="refentry reference" href="./back-inserter.html"><tt class="refentry literal"><span class="pre">back_inserter</span></tt></a></li>
94</ul>
95</div>
96<div class="section" id="inserter-see-also">
97<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
98<p><a class="reference" href="./algorithms.html">Algorithms</a>, <a class="reference" href="./transformation-algorithms.html">Transformation Algorithms</a>, <a class="refentry reference" href="./inserters-inserter.html"><tt class="refentry literal"><span class="pre">inserter</span></tt></a>, <a class="refentry reference" href="./front-inserter.html"><tt class="refentry literal"><span class="pre">front_inserter</span></tt></a>, <a class="refentry reference" href="./back-inserter.html"><tt class="refentry literal"><span class="pre">back_inserter</span></tt></a></p>
99<!-- modtime: November 13, 2004 01:42:40 +0000 -->
100<!-- Algorithms/Concepts//Reversible Algorithm -->
101</div>
102</div>
103
104<div class="footer-separator"></div>
105<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./algorithms-concepts.html" class="navigation-link">Prev</a>&nbsp;<a href="./reversible-algorithm.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./reversible-algorithm.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms-concepts.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>
106</tr></table></body>
107</html>
Note: See TracBrowser for help on using the repository browser.