1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Tiers</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Chapter 1. Fusion 2.2"> 8<link rel="up" href="../functions.html" title="Functions"> 9<link rel="prev" href="make_map.html" title="make_map"> 10<link rel="next" href="list_tie.html" title="list_tie"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<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> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="fusion.container.generation.functions.tiers"></a><a class="link" href="tiers.html" title="Tiers">Tiers</a> 28</h5></div></div></div> 29<p> 30 Tiers are sequences, where all elements are non-const reference types. 31 They are constructed with a call to a couple of <span class="emphasis"><em>tie</em></span> 32 function templates. The succeeding sections document the various <span class="emphasis"><em>tier</em></span> 33 flavors. 34 </p> 35<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 36<li class="listitem"> 37 <a class="link" href="list_tie.html" title="list_tie"><code class="computeroutput"><span class="identifier">list_tie</span></code></a> 38 </li> 39<li class="listitem"> 40 <a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></a> 41 </li> 42<li class="listitem"> 43 <a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">map_tie</span></code></a> 44 </li> 45<li class="listitem"> 46 <a class="link" href="deque_tie.html" title="deque_tie"><code class="computeroutput"><span class="identifier">deque_tie</span></code></a> 47 </li> 48</ul></div> 49<p> 50 Example: 51 </p> 52<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> 53 <span class="special">...</span> 54<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> 55</pre> 56<p> 57 The <a class="link" href="vector_tie.html" title="vector_tie"><code class="computeroutput"><span class="identifier">vector_tie</span></code></a> function creates 58 a <a class="link" href="../../vector.html" title="vector"><code class="computeroutput"><span class="identifier">vector</span></code></a> 59 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 60 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/libs/core/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(i), <a href="http://www.boost.org/libs/core/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(c), <a href="http://www.boost.org/libs/core/ref.html" target="_top"><code class="computeroutput"><span class="identifier">ref</span></code></a>(d)) <a href="#ftn.fusion.container.generation.functions.tiers.f0" class="footnote" name="fusion.container.generation.functions.tiers.f0"><sup class="footnote">[11]</sup></a>. 61 </p> 62<p> 63 A <span class="emphasis"><em>tie</em></span> can be used to 'unpack' another tuple into 64 variables. E.g.: 65 </p> 66<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> 67<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> 68<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> 69</pre> 70<p> 71 This code prints 1 a 5.5 to the standard output stream. A sequence unpacking 72 operation like this is found for example in ML and Python. It is convenient 73 when calling functions which return sequences. 74 </p> 75<h6> 76<a name="fusion.container.generation.functions.tiers.h0"></a> 77 <span class="phrase"><a name="fusion.container.generation.functions.tiers.ignore"></a></span><a class="link" href="tiers.html#fusion.container.generation.functions.tiers.ignore">Ignore</a> 78 </h6> 79<p> 80 There is also an object called <span class="emphasis"><em>ignore</em></span> which allows 81 you to ignore an element assigned by a sequence. The idea is that a function 82 may return a sequence, only part of which you are interested in. For 83 example: 84 </p> 85<pre class="programlisting"><span class="keyword">char</span> <span class="identifier">c</span><span class="special">;</span> 86<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> 87</pre> 88<div class="footnotes"> 89<br><hr style="width:100; text-align:left;margin-left: 0"> 90<div id="ftn.fusion.container.generation.functions.tiers.f0" class="footnote"><p><a href="#fusion.container.generation.functions.tiers.f0" class="para"><sup class="para">[11] </sup></a> 91 see <a href="http://www.boost.org/libs/core/ref.html" target="_top">Ref utility</a> 92 for details about <code class="computeroutput"><span class="identifier">ref</span></code> 93 </p></div> 94</div> 95</div> 96<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 97<td align="left"></td> 98<td align="right"><div class="copyright-footer">Copyright © 2001-2006, 2011, 2012 Joel de Guzman, 99 Dan Marsden, Tobias Schwinger<p> 100 Distributed under the Boost Software License, Version 1.0. (See accompanying 101 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>) 102 </p> 103</div></td> 104</tr></table> 105<hr> 106<div class="spirit-nav"> 107<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> 108</div> 109</body> 110</html> 111