27 Oct
2005
27 Oct
'05
1:06 p.m.
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; }