diff --git a/src/proc/engine/nodewiringconfig.hpp b/src/proc/engine/nodewiringconfig.hpp index 24fd44ad9..a385ce2a2 100644 --- a/src/proc/engine/nodewiringconfig.hpp +++ b/src/proc/engine/nodewiringconfig.hpp @@ -46,9 +46,7 @@ namespace lumiera { struct CondNode { typedef Node Next; }; - template< class TYPES - , template class _P_ - > + template< class TYPES , template class _P_> struct Filter; template class _P_> @@ -57,7 +55,7 @@ namespace lumiera { template< class TY, class TYPES , template class _P_ > - struct Filter,_P_> { typedef typename CondNode<_P_::value + struct Filter,_P_> { typedef typename CondNode< _P_::value , TY , typename Filter::List >::Next @@ -92,7 +90,7 @@ namespace lumiera { template - struct PrefixAll { typedef typename Append::List List; }; + struct PrefixAll { typedef Node< typename Append::List, NullType> List; }; template struct PrefixAll { typedef NullType List; }; @@ -108,7 +106,10 @@ namespace lumiera { template - struct Distribute { typedef typename Append::List List; }; + struct Distribute { typedef typename PrefixAll::List List; }; + + template + struct Distribute,NullType> { typedef Node List; }; template< class TY, class TYPES , class TAIL @@ -148,7 +149,6 @@ namespace lumiera { - using std::max; template struct Flag { typedef Flag ID; }; diff --git a/tests/common/typelistmaniptest.cpp b/tests/common/typelistmaniptest.cpp index 0ae0d08ff..9420aa154 100644 --- a/tests/common/typelistmaniptest.cpp +++ b/tests/common/typelistmaniptest.cpp @@ -61,7 +61,7 @@ namespace lumiera { boost::format fmt ("<%i>"); /** constant-wrapper type for debugging purposes, - * usable for generating lists of distinghishable types + * usable for generating lists of distinguishable types */ template struct Num @@ -77,16 +77,44 @@ namespace lumiera { template struct Printer; + template + struct Printer + { + static string print () { return "-"; } + }; + template struct Printer, BASE> : BASE { static string print () { return string("-") + Num::str() + BASE::print(); } }; - template - struct Printer + + + typedef Printer NullP; + + /** call the debug-print for a typelist + * utilizing the Printer template */ + template + string + printSublist () + { + typedef InstantiateChained SubList; + return SubList::print(); + } + + /** Spezialisation for debug-printing of a nested sublist */ + template + struct Printer, BASE> + : BASE { - static string print () { return "-"; } + static string print () + { + //typedef InstantiateChained, Printer, NullP> SubList; + typedef Node List; + return string("\n\t+--") + printSublist()+"+" + + BASE::print(); + } }; @@ -99,10 +127,16 @@ namespace lumiera { , Num<6> , Num<7> >::List List2; + + + template struct CountDown { typedef NullType List; }; + template<> struct CountDown > { typedef Node, NullType> List; }; + template struct CountDown > { typedef Node, typename CountDown >::List> List; }; + #define DIAGNOSE(LIST) \ - typedef InstantiateChained > Contents_##LIST; + typedef InstantiateChained Contents_##LIST; #define DISPLAY(NAME) \ DIAGNOSE(NAME); cout << STRINGIFY(NAME) << "\t" << Contents_##NAME::print() << "\n"; @@ -116,9 +150,13 @@ namespace lumiera { /************************************************************************* * @test check utilities for manipulating lists-of-types. - *
  • build an list of constant-wrapper-types and - * print them for debugging purpose.
  • - *
+ * - build an list of constant-wrapper-types and + * print them for debugging purpose. + * - append lists, single elements and NullType + * in various combinations + * - filtering out some types from a typelist by + * using a "predicate template" (metafuction) + * - building combinations and permutations */ class TypeListManipl_test : public Test { @@ -126,6 +164,10 @@ namespace lumiera { { check_diagnostics (); check_append (); + check_filter (); + check_prefix (); + check_distribute(); + check_combine(); } @@ -174,6 +216,70 @@ namespace lumiera { DISPLAY (Append9); } + + template struct IsEven { enum {value = false }; }; + template struct IsEven > { enum {value = (0 == I % 2) }; }; + + void check_filter () + { + typedef Filter::List, IsEven > FilterEven; + DISPLAY (FilterEven); + } + + + void check_prefix () + { + typedef PrefixAll,Num<22> > Prefix1; + DISPLAY (Prefix1); + + typedef PrefixAll,List1> Prefix2; + DISPLAY (Prefix2); + + typedef PrefixAll Prefix3; + DISPLAY (Prefix3); + + typedef Types,List2::List>::List List_of_Lists; + typedef PrefixAll,List_of_Lists> Prefix4; + DISPLAY (Prefix4); + + typedef PrefixAll Prefix5; + DISPLAY (Prefix5); + + typedef PrefixAll Prefix6; + DISPLAY (Prefix6); + } + + + void check_distribute() + { + typedef Distribute, List1> Dist1; + DISPLAY (Dist1); + + typedef Types,Num<22>,Num<33> >::List Prefixes; + typedef Distribute > Dist2; + DISPLAY (Dist2); + + typedef Distribute Dist3; + DISPLAY (Dist3); + + typedef Distribute::List> Dist4; + DISPLAY (Dist4); + } + + + void check_combine() + { + typedef CountDown > Down; + DISPLAY (Down); + + typedef Combine Combi; + DISPLAY (Combi); + + typedef CombineFlags OnOff; + DISPLAY (OnOff); + } + + };