I assume the reader is already familiar with tuples (<ahref="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html"target="_top">Boost.Tuple</a>)
and its ancestor <ttclass="computeroutput"><spanclass="identifier">std</span><spanclass="special">::</span><spanclass="identifier">pair</span></tt>. The tuple is a generalization of <ttclass="computeroutput"><spanclass="identifier">std</span><spanclass="special">::</span><spanclass="identifier">pair</span></tt>
for multiple heterogeneous elements (triples, quadruples, etc.). The tuple
is more or less a synonym for fusion's <ttclass="computeroutput"><ahref="container/vector.html"title="vector"><ttclass="computeroutput"><spanclass="identifier">vector</span></tt></a></tt>.
</p>
<p>
For starters, we shall include all of Fusion's <ahref="sequence.html"title="Sequence">Sequence</a>(s)
Let's begin with a <ttclass="computeroutput"><ahref="container/vector.html"title="vector"><ttclass="computeroutput"><spanclass="identifier">vector</span></tt></a></tt>
Just replace <ttclass="computeroutput"><spanclass="identifier">tuple</span></tt> for <ttclass="computeroutput"><ahref="container/vector.html"title="vector"><ttclass="computeroutput"><spanclass="identifier">vector</span></tt></a></tt>
and <ttclass="computeroutput"><spanclass="identifier">get</span></tt> for <ttclass="computeroutput"><ahref="sequence/intrinsic/functions/at_c.html"title="at_c"><ttclass="computeroutput"><spanclass="identifier">at_c</span></tt></a></tt> and this is exactly like
Actually, either names can be used interchangeably. Yet, the similarity ends
there. You can do a lot more with Fusion <ttclass="computeroutput"><ahref="container/vector.html"title="vector"><ttclass="computeroutput"><spanclass="identifier">vector</span></tt></a></tt> or <ttclass="computeroutput"><spanclass="identifier">tuple</span></tt>.
That's it! <ttclass="computeroutput"><ahref="algorithm/iteration/functions/for_each.html"title="for_each"><ttclass="computeroutput"><spanclass="identifier">for_each</span></tt></a></tt> is a fusion algorithm.
It is a generic algorithm similar to <ahref="http://en.wikipedia.org/wiki/Standard_Template_Library"target="_top">STL</a>'s.
It iterates over the sequence and calls a user supplied function. In our case,
it calls <ttclass="computeroutput"><spanclass="identifier">print_xml</span></tt>'s <ttclass="computeroutput"><spanclass="keyword">operator</span><spanclass="special">()</span></tt> for
each element in <ttclass="computeroutput"><spanclass="identifier">stuff</span></tt>.
The result of <ttclass="computeroutput"><spanclass="keyword">typeid</span><spanclass="special">(</span><spanclass="identifier">x</span><spanclass="special">).</span><spanclass="identifier">name</span><spanclass="special">()</span></tt> is platform specific. The code here is
just for exposition. Of course you already know that :-)
</p></td></tr>
</table></div>
<p>
<ttclass="computeroutput"><ahref="algorithm/iteration/functions/for_each.html"title="for_each"><ttclass="computeroutput"><spanclass="identifier">for_each</span></tt></a></tt> is generic. With
<ttclass="computeroutput"><spanclass="identifier">print_xml</span></tt>, you can use it to
print just about any Fusion <ahref="sequence.html"title="Sequence">Sequence</a>.
<ttclass="computeroutput"><ahref="algorithm/transformation/functions/filter_if.html"title="filter_if"><ttclass="computeroutput"><spanclass="identifier">filter_if</span></tt></a></tt> is another Fusion
algorithm. It returns a <ahref="view/filter_view.html"title="filter_view"><ttclass="computeroutput"><spanclass="identifier">filter_view</span></tt></a>, a conforming Fusion sequence.
This view reflects only those elements that pass the given predicate. In this
case, the predicate is <ttclass="computeroutput"><spanclass="identifier">boost</span><spanclass="special">::</span><spanclass="identifier">is_pointer</span><spanclass="special"><</span><spanclass="identifier">_</span><spanclass="special">></span></tt>.
This "filtered view" is then passed to the <ahref="algorithm/iteration/functions/for_each.html"title="for_each"><ttclass="computeroutput"><spanclass="identifier">for_each</span></tt></a> algorithm, which then prints
Apart from <ttclass="computeroutput"><ahref="container/vector.html"title="vector"><ttclass="computeroutput"><spanclass="identifier">vector</span></tt></a></tt>,
fusion has a couple of other sequence types to choose from. Each sequence has
its own characteristics. We have <ttclass="computeroutput"><ahref="container/list.html"title="list"><ttclass="computeroutput"><spanclass="identifier">list</span></tt></a></tt>, <ttclass="computeroutput"><ahref="container/set.html"title="set"><ttclass="computeroutput"><spanclass="identifier">set</span></tt></a></tt>, <ttclass="computeroutput"><ahref="container/map.html"title="map"><ttclass="computeroutput"><spanclass="identifier">map</span></tt></a></tt>, plus a multitude of <ttclass="computeroutput"><spanclass="identifier">views</span></tt> that provide various ways to present
is an associative sequence. Its elements are Fusion pairs which differ somewhat
from <ttclass="computeroutput"><spanclass="identifier">std</span><spanclass="special">::</span><spanclass="identifier">pair</span></tt>. Fusion pairs only contain one member,
with the type of their second template parameter. The first type parameter
of the pair is used as an index to the associated element in the sequence.
For example, given a <ttclass="computeroutput"><spanclass="identifier">a_person</span></tt>
of type, <ttclass="computeroutput"><spanclass="identifier">person</span></tt>, you can do:
Why go through all this trouble, you say? Well, for one, unlike the <ttclass="computeroutput"><spanclass="keyword">struct</span></tt>, we are dealing with a generic data structure.
There are a multitude of facilities available at your disposal provided out
of the box with fusion or written by others. With these facilities, introspection
comes for free, for example. We can write one serialization function (well,
two, if you consider loading and saving) that will work for all your fusion
The <ttclass="computeroutput"><spanclass="identifier">save</span></tt> function is generic
and will work for all types of <ttclass="computeroutput"><spanclass="identifier">stuff</span></tt>
regardless if it is a <ttclass="computeroutput"><spanclass="identifier">person</span></tt>,
a <ttclass="computeroutput"><spanclass="identifier">dog</span></tt> or a whole <ttclass="computeroutput"><spanclass="identifier">alternate_universe</span></tt>.
Unless otherwise noted, components are in namespace <ttclass="computeroutput"><spanclass="identifier">boost</span><spanclass="special">::</span><spanclass="identifier">fusion</span></tt>.
For the sake of simplicity, code in this quick start implies <ttclass="computeroutput"><spanclass="keyword">using</span></tt> directives for the fusion components