forked from boostorg/fusion
172 lines
12 KiB
HTML
172 lines
12 KiB
HTML
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||
<title>Tiers</title>
|
||
<link rel="stylesheet" href="../../../../../../../../doc/html/boostbook.css" type="text/css">
|
||
<<<<<<< .working
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.65.1">
|
||
=======
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
|
||
<<<<<<< .working
|
||
>>>>>>> .merge-right.r57125
|
||
<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.0">
|
||
=======
|
||
<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.0">
|
||
>>>>>>> .merge-right.r58299
|
||
<link rel="up" href="../functions.html" title="Functions">
|
||
<link rel="previous" href="make_map.html" title="make_map">
|
||
<link rel="next" href="list_tie.html" title="list_tie">
|
||
</head>
|
||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
<table cellpadding="2" width="100%"><tr>
|
||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
|
||
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
|
||
<td align="center"><a href="../../../../../../../libraries.htm">Libraries</a></td>
|
||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav">
|
||
<a accesskey="p" href="make_map.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="list_tie.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
|
||
</div>
|
||
<div class="section" lang="en">
|
||
<div class="titlepage">
|
||
<div><div><h5 class="title">
|
||
<a name="fusion.container.generation.functions.tiers"></a><a href="tiers.html" title="Tiers">Tiers</a>
|
||
</h5></div></div>
|
||
<div></div>
|
||
</div>
|
||
<p>
|
||
Tiers are sequences, where all elements are non-const reference types.
|
||
They are constructed with a call to a couple of <span class="emphasis"><em>tie</em></span>
|
||
function templates. The succeeding sections document the various <span class="emphasis"><em>tier</em></span>
|
||
flavors.
|
||
</p>
|
||
<div class="itemizedlist"><ul type="disc">
|
||
<li><a href="list_tie.html" title="list_tie"><tt class="computeroutput"><span class="identifier">list_tie</span></tt></a></li>
|
||
<li><a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">vector_tie</span></tt></a></li>
|
||
<li><a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">map_tie</span></tt></a></li>
|
||
</ul></div>
|
||
<p>
|
||
Example:
|
||
</p>
|
||
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span> <span class="keyword">char</span> <span class="identifier">c</span><span class="special">;</span> <span class="keyword">double</span> <span class="identifier">d</span><span class="special">;</span>
|
||
<span class="special">...</span>
|
||
<a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">vector_tie</span></tt></a><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">a</span><span class="special">);</span>
|
||
</pre>
|
||
<p>
|
||
<<<<<<< .working
|
||
The <a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">vector_tie</span></tt></a> function creates
|
||
a <a href="../../vector.html" title="vector"><tt class="computeroutput"><span class="identifier">vector</span></tt></a>
|
||
of type <tt class="computeroutput"><a href="../../vector.html" title="vector"><tt class="computeroutput"><span class="identifier">vector</span></tt></a><span class="special"><</span><span class="keyword">int</span><span class="special">&,</span> <span class="keyword">char</span><span class="special">&,</span> <span class="keyword">double</span><span class="special">&></span></tt>. The same result could be achieved
|
||
with the call <a href="make_vector.html" title="make_vector"><tt class="computeroutput"><span class="identifier">make_vector</span></tt></a>(<a href="http://www.boost.org/doc/html/ref.html" target="_top"><tt class="computeroutput"><span class="identifier">ref</span></tt></a>(i), <a href="http://www.boost.org/doc/html/ref.html" target="_top"><tt class="computeroutput"><span class="identifier">ref</span></tt></a>(c), <a href="http://www.boost.org/doc/html/ref.html" target="_top"><tt class="computeroutput"><span class="identifier">ref</span></tt></a>(a))
|
||
<sup>[<a name="id495412" href="#ftn.id495412">9</a>]</sup>
|
||
=======
|
||
The <a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></a> function creates
|
||
a <a class="link" href="../../vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a>
|
||
of type <code class="computeroutput"><a class="link" href="../../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">char</span><span class="special">&,</span> <span class="keyword">double</span><span class="special">&></span></code>. The same result could be achieved
|
||
with the call <a class="link" href="make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></a>(<a href="http://www.boost.org/doc/html/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(i), <a href="http://www.boost.org/doc/html/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(c), <a href="http://www.boost.org/doc/html/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(a))
|
||
<sup>[<a name="id709333" href="#ftn.id709333" class="footnote">9</a>]</sup>
|
||
>>>>>>> .merge-right.r57125
|
||
.
|
||
</p>
|
||
<p>
|
||
A <span class="emphasis"><em>tie</em></span> can be used to 'unpack' another tuple into
|
||
variables. E.g.:
|
||
</p>
|
||
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span> <span class="keyword">char</span> <span class="identifier">c</span><span class="special">;</span> <span class="keyword">double</span> <span class="identifier">d</span><span class="special">;</span>
|
||
<a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">vector_tie</span></tt></a><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">d</span><span class="special">)</span> <span class="special">=</span> <a href="make_vector.html" title="make_vector"><tt class="computeroutput"><span class="identifier">make_vector</span></tt></a><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="char">'a'</span><span class="special">,</span> <span class="number">5.5</span><span class="special">);</span>
|
||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">i</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="identifier">c</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="identifier">d</span><span class="special">;</span>
|
||
</pre>
|
||
<p>
|
||
This code prints 1 a 5.5 to the standard output stream. A sequence unpacking
|
||
operation like this is found for example in ML and Python. It is convenient
|
||
when calling functions which return sequences.
|
||
</p>
|
||
<a name="fusion.container.generation.functions.tiers.ignore"></a><h6>
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<a name="id495712"></a>
|
||
<a href="tiers.html#fusion.container.generation.functions.tiers.ignore">Ignore</a>
|
||
=======
|
||
<a name="id747017"></a>
|
||
=======
|
||
<a name="id709430"></a>
|
||
=======
|
||
<a name="id701785"></a>
|
||
=======
|
||
<a name="id723054"></a>
|
||
=======
|
||
<a name="id712830"></a>
|
||
=======
|
||
<a name="id709553"></a>
|
||
>>>>>>> .merge-right.r58559
|
||
>>>>>>> .merge-right.r58549
|
||
>>>>>>> .merge-right.r58299
|
||
>>>>>>> .merge-right.r57337
|
||
>>>>>>> .merge-right.r57242
|
||
<a class="link" href="tiers.html#fusion.container.generation.functions.tiers.ignore">Ignore</a>
|
||
>>>>>>> .merge-right.r57125
|
||
</h6>
|
||
<p>
|
||
There is also an object called <span class="emphasis"><em>ignore</em></span> which allows
|
||
you to ignore an element assigned by a sequence. The idea is that a function
|
||
may return a sequence, only part of which you are interested in. For
|
||
example:
|
||
</p>
|
||
<pre class="programlisting"><span class="keyword">char</span> <span class="identifier">c</span><span class="special">;</span>
|
||
<a href="vector_tie.html" title="vector_tie"><tt class="computeroutput"><span class="identifier">vector_tie</span></tt></a><span class="special">(</span><span class="identifier">ignore</span><span class="special">,</span> <span class="identifier">c</span><span class="special">)</span> <span class="special">=</span> <a href="make_vector.html" title="make_vector"><tt class="computeroutput"><span class="identifier">make_vector</span></tt></a><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="char">'a'</span><span class="special">);</span>
|
||
</pre>
|
||
<div class="footnotes">
|
||
<br><hr width="100" align="left">
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<<<<<<< .working
|
||
<div class="footnote"><p><sup>[<a name="ftn.id495412" href="#id495412">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id746798" href="#id746798" class="para">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id709211" href="#id709211" class="para">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id701565" href="#id701565" class="para">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id722834" href="#id722834" class="para">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id712610" href="#id712610" class="para">9</a>] </sup>
|
||
=======
|
||
<div class="footnote"><p><sup>[<a name="ftn.id709333" href="#id709333" class="para">9</a>] </sup>
|
||
>>>>>>> .merge-right.r58559
|
||
>>>>>>> .merge-right.r58549
|
||
>>>>>>> .merge-right.r58299
|
||
>>>>>>> .merge-right.r57337
|
||
>>>>>>> .merge-right.r57242
|
||
>>>>>>> .merge-right.r57125
|
||
see <a href="http://www.boost.org/doc/html/ref.html" target="_top">Boost.Ref</a>
|
||
for details about <tt class="computeroutput"><span class="identifier">ref</span></tt>
|
||
</p></div>
|
||
</div>
|
||
</div>
|
||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||
<td align="left"></td>
|
||
<td align="right"><div class="copyright-footer">Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias
|
||
Schwinger<p>
|
||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
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>)
|
||
</p>
|
||
</div></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav">
|
||
<a accesskey="p" href="make_map.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="list_tie.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
|
||
</div>
|
||
</body>
|
||
</html>
|