An advantage other languages such as Python and Lisp/ Scheme, ML and Haskell,
etc., over C++ is the ability to have heterogeneous containers that can hold
arbitrary element types. All the containers in the standard library can only
hold a specific type. A <ttclass="computeroutput"><spanclass="identifier">vector</span><spanclass="special"><</span><spanclass="keyword">int</span><spanclass="special">></span></tt>
can only hold <ttclass="computeroutput"><spanclass="keyword">int</span></tt>s. A <ttclass="computeroutput"><spanclass="identifier">list</span><spanclass="special"><</span><spanclass="identifier">X</span><spanclass="special">></span></tt> can
only hold elements of type <ttclass="computeroutput"><spanclass="identifier">X</span></tt>,
and so on.
</p>
<p>
True, you can use inheritance to make the containers hold different types,
related through subclassing. However, you have to hold the objects through
a pointer or smart reference of some sort. Doing this, you'll have to rely
on virtual functions to provide polymorphic behavior since the actual type
is erased as soon as you store a pointer to a derived class to a pointer to
its base. The held objects must be related: you cannot hold objects of unrelated
types such as <ttclass="computeroutput"><spanclass="keyword">char</span></tt>, <ttclass="computeroutput"><spanclass="keyword">int</span></tt>, <ttclass="computeroutput"><spanclass="keyword">class</span>
fusion algorithms are functional in nature such that algorithms are non mutating
(no side effects). However, due to the high cost of returning full sequences
such as vectors and lists, <spanclass="emphasis"><em>Views</em></span> are returned from Fusion
algorithms instead. For example, the <ahref="algorithm/transformation/functions/transform.html"title="transform"><ttclass="computeroutput"><spanclass="identifier">transform</span></tt></a> algorithm does not actually
return a transformed version of the original sequence. <ahref="algorithm/transformation/functions/transform.html"title="transform"><ttclass="computeroutput"><spanclass="identifier">transform</span></tt></a> returns a <ahref="view/transform_view.html"title="transform_view"><ttclass="computeroutput"><spanclass="identifier">transform_view</span></tt></a>. This view holds a
reference to the original sequence plus the transform function. Iteration over
the <ahref="view/transform_view.html"title="transform_view"><ttclass="computeroutput"><spanclass="identifier">transform_view</span></tt></a>
will apply the transform function over the sequence elements on demand. This
<spanclass="emphasis"><em>lazy</em></span> evaluation scheme allows us to chain as many algorithms
as we want without incurring a high runtime penalty.
</p>
<p>
The <spanclass="emphasis"><em>lazy</em></span> evaluation scheme where algorithms return views
allows operations such as <ahref="algorithm/transformation/functions/push_back.html"title="push_back"><ttclass="computeroutput"><spanclass="identifier">push_back</span></tt></a> to be totally generic. In
Fusion, <ahref="algorithm/transformation/functions/push_back.html"title="push_back"><ttclass="computeroutput"><spanclass="identifier">push_back</span></tt></a> is actually a generic algorithm
that works on all sequences. Given an input sequence <ttclass="computeroutput"><spanclass="identifier">s</span></tt>
and a value <ttclass="computeroutput"><spanclass="identifier">x</span></tt>, Fusion's <ahref="algorithm/transformation/functions/push_back.html"title="push_back"><ttclass="computeroutput"><spanclass="identifier">push_back</span></tt></a> algorithm simply returns
a <ahref="view/joint_view.html"title="joint_view"><ttclass="computeroutput"><spanclass="identifier">joint_view</span></tt></a>:
a view that holds a reference to the original sequence <ttclass="computeroutput"><spanclass="identifier">s</span></tt>
and the value <ttclass="computeroutput"><spanclass="identifier">x</span></tt>. Functions
that were once sequence specific and need to be implemented N times over N
different sequences are now implemented only once.
</p>
<p>
Fusion provides full round compatibility with <ahref="http://www.boost.org/libs/mpl/index.html"target="_top">MPL</a>.
Fusion sequences are fully conforming <ahref="http://www.boost.org/libs/mpl/index.html"target="_top">MPL</a>
sequences and <ahref="http://www.boost.org/libs/mpl/index.html"target="_top">MPL</a>
sequences are fully compatible with Fusion. You can work with Fusion sequences
on <ahref="http://www.boost.org/libs/mpl/index.html"target="_top">MPL</a> if you
wish to work solely on types. In <ahref="http://www.boost.org/libs/mpl/index.html"target="_top">MPL</a>,