...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Tutorial: Metafunctions and Higher-Order Metaprogramming / Lambda Details / Lambda and Non-Metafunction Templates |
There is just one detail of placeholder expressions that we haven't discussed yet. MPL uses a special rule to make it easier to integrate ordinary templates into metaprograms: After all of the placeholders have been replaced with actual arguments, if the resulting template specialization X doesn't have a nested ::type, the result is just X itself.
For example, mpl::apply
// trivial std::vector generator templatestruct make_vector { typedef std::vector type; }; typedef mpl::apply<make_vector<_>, T>::type vector_of_t;
Instead, we can simply write:
typedef mpl::apply<std::vector<_>, T>::type vector_of_t;