For a small library project, I use boost :: tuple. Right now, I am faced with the problem of turning the "list of minuses" that I worked with, using metaprogramming back to type boost :: tuple <...>. A "dirty" solution would be to provide many side effects a la
template<class T> struct id{typedef T type;};
template<class TL> struct type_list_to_tuple_type;
template<class T1>
struct type_list_to_tuple_type<
boost::tuples::cons<T1,boost::tuples::null_type>
> : id<boost::tuple<T1> > {}
template<class T1, class T2>
struct type_list_to_tuple_type<
boost::tuples::cons<T1,
boost::tuples::cons<T2,boost::tuples::null_type> >
> : id<boost::tuple<T1,T2> > {}
template<class T1, class T2, class T3>
struct type_list_to_tuple_type<
boost::tuples::cons<T1,
boost::tuples::cons<T2,
boost::tuples::cons<T3,boost::tuples::null_type> > >
> : id<boost::tuple<T1,T2,T3> > {}
...
But this is tedious and error prone, especially because I need tuple support with as many elements as possible. These types of tuples are automatically generated when the operator is overloaded. If possible, I would like not to write so many specializations.
, - ++ 0x? , . , , - .
: ++ 0x , , :
template<class TPH>
class type_pack_holder_to_tuple_type;
template<class...Types>
class type_pack_holder_to_tuple_type<
type_pack_holder<Types...> >
: id< boost::tuple<Types...> > {};
g++ 4.5.1 :
sorry, unimplemented: cannot expand 'Types ...' into
a fixed-length argument list
: - (