Re: [Boost-users] multi-inheritance from elements of mpl::vector? ==> inherit_scattered ( for Barton & Nackmann trick)
Is there a page somewhere that describes the trick, just out of interest like.
C++ Template Metaprogramming, page 205 Modern C++ Design, somewhere AFAIK - Barton & Nackmann trick is used for class composition: template< typename Derived > struct Add { int add() { // B & N-trick: access to the Composed class D & d = static_cast< Derived & >( * this); return d.first() + d.second(); } }; struct First { int first() { return 1; } }; struct Second { int second() { return 2; } }; class Composed : inherit_scattered< vector< First, Second, Add< Composed > > > {}; void main() { Composed c; Std::cout << c.add() << std::endl; }
Is there a page somewhere that describes the trick, just out of interest like.
C++ Template Metaprogramming, page 205 Modern C++ Design, somewhere
AFAIK - Barton & Nackmann trick is used for class composition:
See http://en.wikipedia.org/wiki/Barton-Nackman for a more accurate description. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Oliver.Kowalke@infineon.com