/******************************************************************** created: 2008/06/13 created: 13:6:2008 12:47 filename: d:\Projects\ServiceSpace\ServiceSpace\ServiceSpaceLib\tuple_foreach.h file path: d:\Projects\ServiceSpace\ServiceSpace\ServiceSpaceLib file base: tuple_foreach file ext: h author: purpose: *********************************************************************/ #ifndef __SERVICE_SPACE_TUPLE_FOREACH_H__ #define __SERVICE_SPACE_TUPLE_FOREACH_H__ #include "tuple.h" #include "int2type.h" namespace utilib { namespace __internal { template struct tuple_foreach_i; template struct tuple_foreach_i, Vistor, Index> { typedef tuple<> tuple_type; tuple_foreach_i(tuple_type & tu, Vistor &) { } }; /* template*/ template struct tuple_foreach_i { typedef Tuple tuple_type; #ifdef WIN32 template struct _foreach_i; template<> struct _foreach_i { static void do_foreach(tuple_type & tu, Vistor & vistor) { } }; template<> struct _foreach_i { static void do_foreach(tuple_type & tu, Vistor & vistor) { if (0 == vistor(tu.value())) tuple_foreach_i(tu, vistor); } }; tuple_foreach_i(tuple_type & tu, Vistor & vistor) { _foreach_i::type>::Result>::do_foreach(tu, vistor); } #endif }; } // namespace __internal template struct tuple_foreach : protected __internal::tuple_foreach_i { private: typedef __internal::tuple_foreach_i base; public: tuple_foreach(Tuple & tu, Vistor & vistor) : base(tu, vistor) { } }; //#ifdef WIN32 //#else template void do_tuple_foreach_i(Tuple & tu, Vistor & vistor, int2type) { //vistor(tu.value()); int2type t; vistor(tu.value_i(t)); do_tuple_foreach_i(tu, vistor, int2type()); } template void do_tuple_foreach_i(Tuple & tu, Vistor & vistor, int2type<0> ) { //vistor(tu.value<0>()); int2type<0> t; vistor(tu.value_i(t)); } //#endif template void do_tuple_foreach(Tuple & tu, Vistor & vistor) { #ifdef WIN32 tuple_foreach(tu, vistor); #else do_tuple_foreach_i(tu, vistor, int2type()); #endif } } #endif