There are situations when it would be great to work with all the template parameters as if they were in a container. Imagine that we are writing something such as Boost.Variant
:
#include <boost/mpl/aux_/na.hpp> // boost::mpl::na == n.a. == not available template < class T0 = boost::mpl::na, class T1 = boost::mpl::na, class T2 = boost::mpl::na, class T3 = boost::mpl::na, class T4 = boost::mpl::na, class T5 = boost::mpl::na, class T6 = boost::mpl::na, class T7 = boost::mpl::na, class T8 = boost::mpl::na, class T9 = boost::mpl::na > struct variant;
And the preceding code is where all the following interesting tasks start to happen:
How can we remove constant and volatile qualifiers from all the types?
How can we remove duplicate types?
How can we get the sizes of all the types?
How can we get the maximum size of the input parameters?
All these tasks can be easily solved using Boost.MPL
.