December 2004
Intermediate to advanced
400 pages
8h 29m
English
Even with the full power of template metaprogramming and the Boost Metaprogramming Library at our disposal, some C++ coding jobs still require a great deal of boilerplate code repetition. We saw one example in Chapter 5, when we implemented tiny_size:
template <class T0, class T1, class T2> struct tiny_size : mpl::int_<3> {};
Aside from the repeated pattern in the parameter list of the primary template above, there are three partial specializations below, which also follow a predictable pattern:
template <class T0, class T1> struct tiny_size<T0,T1,none> : mpl::int_<2> {}; template <class T0> struct tiny_size<T0,none,none> : mpl::int_<1> {}; ...
Read now
Unlock full access