#include #include #include "HierarchyGenerators.h" using namespace Loki; template void PrintType(T &) { printf("%s\n", typeid(T).name()); } template class PrintTuple { public: template explicit PrintTuple(const T &x) { PrintTuple X(x); PrintType(Field(x)); } }; template<> class PrintTuple<0> { public: template explicit PrintTuple(const T &x) { PrintType(Field<0>(x)); } }; template void PrintTupleFunc() { T x; PrintTuple::value - 1> X(x); } template struct A {}; int main() { typedef TYPELIST_11(A<1>, A<1>, int, int, A<1>, A<2>, int[10], int, int *, A<2>, A<3>) typelist_t; typedef Tuple tuple_t; PrintTupleFunc(); tuple_t X; A<3> Y = Field< A<3> >(X); // without -Za warning C4239: nonstandard extension used // this is because VC sometimes binds temporary to non-const reference // which leads to selecting the wrong Field function (non-const version) // fixed in VC7.1 Y = Field< A<3> >(tuple_t()); A<3> &Y1 = Field< A<3> >(X); Y1 = Y; }