forked from boostorg/fusion
102 lines
8.9 KiB
HTML
102 lines
8.9 KiB
HTML
![]() |
<html>
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|||
|
<title>Tiers</title>
|
|||
|
<link rel="stylesheet" href="../../../../boostbook.css" type="text/css">
|
|||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1">
|
|||
|
<link rel="start" href="../../../../index.html" title="Chapter<65>1.<2E>Fusion 2.0">
|
|||
|
<link rel="up" href="../functions.html" title="Functions">
|
|||
|
<link rel="prev" 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.htm">Home</a></td>
|
|||
|
<td align="center"><a href="../../../../../../../libraries.htm">Libraries</a></td>
|
|||
|
<td align="center"><a href="../../../../../../../../people/people.htm">People</a></td>
|
|||
|
<td align="center"><a href="../../../../../../../../more/faq.htm">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>
|
|||
|
<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>
|
|||
|
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="id541640" href="#ftn.id541640">10</a>]</sup>
|
|||
|
.
|
|||
|
</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>
|
|||
|
<a name="id541946"></a>
|
|||
|
<a href="tiers.html#fusion.container.generation.functions.tiers.ignore">Ignore</a>
|
|||
|
</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">
|
|||
|
<div class="footnote"><p><sup>[<a name="ftn.id541640" href="#id541640">10</a>] </sup>
|
|||
|
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"><small>Copyright <20> 2001-2007 Joel de Guzman, Dan Marsden, Tobias
|
|||
|
Schwinger</small></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>
|