Boost logo

Boost Users :

Subject: Re: [Boost-users] mpl and fusion containers: numbered vs variadic
From: Christopher Schmidt (christopher_at_[hidden])
Date: 2012-05-27 18:44:11


Larry Evans <cppljevans_at_[hidden]> writes:

> Could you please provide an example implementation of this C++11
> implementation? I've no idea how template aliases could be used :(

Actually it is the other way round, the language feature is called alias
template. (N3337, 14.5.7)

    template <typename...> class container;

    template <typename A>
    using container1 = container<A>;

This is pretty cool because AFAIK from a typization point of view there
is no difference between container<A> and container1<A>. This is
incredibly useful when one uses specialisations instead of explicit
template metaprogramming to optimise in regard to compile-time as it is
being done, for example, in Boost.Spirit. Other than that, the numeric
aliases can easily be generated using the preprocessor and there is no
real overhead imposed to the compilation session.

Even better, one can use template aliases to define the front-end Fusion
container types in terms of a single, shared backend implementation.
This is useful because that way there are way less heavy template
instantiations as the containers now do not built up-on each other any
more.

        Christopher


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net