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 | <!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost --> |
---|
5 | <!-- Software License, Version 1.0. (See accompanying --> |
---|
6 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
---|
7 | <head> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
9 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
---|
10 | <title>The MPL Reference Manual: Inserter</title> |
---|
11 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
---|
12 | </head> |
---|
13 | <body class="docframe refmanual"> |
---|
14 | <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> <a href="./reversible-algorithm.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group">Back <a href="./reversible-algorithm.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./algorithms-concepts.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
---|
15 | <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> |
---|
16 | </tr></table><div class="header-separator"></div> |
---|
17 | <div class="section" id="inserter"> |
---|
18 | <h1><a class="toc-backref" href="./algorithms-concepts.html#id390" name="inserter">Inserter</a></h1> |
---|
19 | <div class="section" id="inserter-description"> |
---|
20 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
---|
21 | <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>. |
---|
22 | Under the hood, it's simply a type holding |
---|
23 | two entities: a <em>state</em> and an <em>operation</em>. When passed to a |
---|
24 | <a class="reference" href="./transformation-algorithms.html">transformation algorithm</a>, the inserter's binary operation is |
---|
25 | invoked for every element that would normally be written into the |
---|
26 | output iterator, with the element itself (as the second |
---|
27 | argument) and the result of the previous operation's invocation — or, |
---|
28 | for the very first element, the inserter's initial state.</p> |
---|
29 | <p>Technically, instead of taking a single inserter parameter, |
---|
30 | <a class="reference" href="./transformation-algorithms.html">transformation algorithms</a> could accept the state and the "output" |
---|
31 | operation separately. Grouping these in a single parameter entity, |
---|
32 | however, brings the algorithms semantically and syntactically closer to |
---|
33 | their STL counterparts, significantly simplifying many of the common |
---|
34 | use cases.</p> |
---|
35 | </div> |
---|
36 | <div class="section" id="valid-expressions"> |
---|
37 | <h3><a class="subsection-title" href="#valid-expressions" name="valid-expressions">Valid expressions</a></h3> |
---|
38 | <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> |
---|
39 | <table border="1" class="table"> |
---|
40 | <colgroup> |
---|
41 | <col width="43%" /> |
---|
42 | <col width="57%" /> |
---|
43 | </colgroup> |
---|
44 | <thead valign="bottom"> |
---|
45 | <tr><th>Expression</th> |
---|
46 | <th>Type</th> |
---|
47 | </tr> |
---|
48 | </thead> |
---|
49 | <tbody valign="top"> |
---|
50 | <tr><td><tt class="literal"><span class="pre">in::state</span></tt></td> |
---|
51 | <td>Any type</td> |
---|
52 | </tr> |
---|
53 | <tr><td><tt class="literal"><span class="pre">in::operation</span></tt></td> |
---|
54 | <td>Binary <a class="reference" href="./lambda-expression.html">Lambda Expression</a></td> |
---|
55 | </tr> |
---|
56 | </tbody> |
---|
57 | </table> |
---|
58 | </div> |
---|
59 | <div class="section" id="inserter-expression-semantics"> |
---|
60 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
---|
61 | <table border="1" class="table"> |
---|
62 | <colgroup> |
---|
63 | <col width="35%" /> |
---|
64 | <col width="65%" /> |
---|
65 | </colgroup> |
---|
66 | <thead valign="bottom"> |
---|
67 | <tr><th>Expression</th> |
---|
68 | <th>Semantics</th> |
---|
69 | </tr> |
---|
70 | </thead> |
---|
71 | <tbody valign="top"> |
---|
72 | <tr><td><tt class="literal"><span class="pre">in::state</span></tt></td> |
---|
73 | <td>The inserter's initial state.</td> |
---|
74 | </tr> |
---|
75 | <tr><td><tt class="literal"><span class="pre">in::operation</span></tt></td> |
---|
76 | <td>The inserter's "output" operation.</td> |
---|
77 | </tr> |
---|
78 | </tbody> |
---|
79 | </table> |
---|
80 | </div> |
---|
81 | <div class="section" id="inserter-example"> |
---|
82 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
---|
83 | <pre class="literal-block"> |
---|
84 | typedef <a href="./transform.html" class="identifier">transform</a>< |
---|
85 | <a href="./range-c.html" class="identifier">range_c</a><int,0,10> |
---|
86 | , <a href="./plus.html" class="identifier">plus</a><_1,_1> |
---|
87 | , <a href="./back-inserter.html" class="identifier">back_inserter</a>< vector0<> > |
---|
88 | >::type result; |
---|
89 | </pre> |
---|
90 | </div> |
---|
91 | <div class="section" id="inserter-models"> |
---|
92 | <h3><a class="subsection-title" href="#models" name="models">Models</a></h3> |
---|
93 | <ul class="simple"> |
---|
94 | <li><a class="refentry reference" href="./inserters-inserter.html"><tt class="refentry literal"><span class="pre">inserter</span></tt></a></li> |
---|
95 | <li><a class="refentry reference" href="./front-inserter.html"><tt class="refentry literal"><span class="pre">front_inserter</span></tt></a></li> |
---|
96 | <li><a class="refentry reference" href="./back-inserter.html"><tt class="refentry literal"><span class="pre">back_inserter</span></tt></a></li> |
---|
97 | </ul> |
---|
98 | </div> |
---|
99 | <div class="section" id="inserter-see-also"> |
---|
100 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
---|
101 | <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> |
---|
102 | <!-- modtime: November 13, 2004 01:42:40 +0000 --> |
---|
103 | <!-- Algorithms/Concepts//Reversible Algorithm --> |
---|
104 | </div> |
---|
105 | </div> |
---|
106 | |
---|
107 | <div class="footer-separator"></div> |
---|
108 | <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> <a href="./reversible-algorithm.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group">Back <a href="./reversible-algorithm.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./algorithms-concepts.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
---|
109 | </tr></table></body> |
---|
110 | </html> |
---|