forked from boostorg/fusion
108 lines
9.6 KiB
HTML
108 lines
9.6 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>Tiers</title>
|
|
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
|
<link rel="home" href="../../../../index.html" title="Chapter 1. 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.html">Home</a></td>
|
|
<td align="center"><a href="../../../../../../../../libs/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/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_tie.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h5 class="title">
|
|
<a name="fusion.container.generation.functions.tiers"></a><a class="link" 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 class="itemizedlist" type="disc">
|
|
<li class="listitem">
|
|
<a class="link" href="list_tie.html" title="list_tie"><code class="computeroutput"><span class="identifier">list_tie</span></code></a>
|
|
</li>
|
|
<li class="listitem">
|
|
<a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></a>
|
|
</li>
|
|
<li class="listitem">
|
|
<a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">map_tie</span></code></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 class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></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 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="id925802" href="#ftn.id925802" class="footnote">9</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 class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></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 class="link" href="make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></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="id926022"></a>
|
|
<a class="link" 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 class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></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 class="link" href="make_vector.html" title="make_vector"><code class="computeroutput"><span class="identifier">make_vector</span></code></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.id925802" href="#id925802" class="para">9</a>] </sup>
|
|
see <a href="http://www.boost.org/doc/html/ref.html" target="_top">Boost.Ref</a>
|
|
for details about <code class="computeroutput"><span class="identifier">ref</span></code>
|
|
</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/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../functions.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="list_tie.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|