#include #include #include "HierarchyGenerators.h" using namespace ::Loki; // // Helper class for simulating (ranking) partial ordering // template struct Order : Order {}; template<> struct Order<0> {}; template class Unit, class Root> class PrintGenLinearHierarchy { template static void Print(GenLinearHierarchy, Unit, Root> &a, Order<0>) { printf("%s\n", typeid(a).name()); Unit > &base1 = a; printf("%s\n", typeid(base1).name()); GenLinearHierarchy &base2 = base1; Print(base2); } template static void Print(GenLinearHierarchy, Unit, Root> &a, Order<1>) { printf("%s\n", typeid(a).name()); Unit &base1 = a; printf("%s\n", typeid(base1).name()); Root &base2 = base1; (void)base2; printf("%s\n", typeid(base2).name()); } public: template static void Print(GenLinearHierarchy, Unit, Root> &a) { Print(a, Order<1>()); } }; template class TestUnit : public Base {}; class TestRoot {}; template struct A {}; template struct B {}; int main() { typedef TYPELIST_20(A<1>, A<2>, A<3>, A<4>, A<5>, A<6>, A<7>, A<8>, A<9>, A<10>, B<1>, B<2>, B<3>, B<4>, B<5>, B<6>, B<7>, B<8>, B<9>, B<10>) TestList_t; GenLinearHierarchy TestGenLinearHierarchy; PrintGenLinearHierarchy::Print(TestGenLinearHierarchy); }