I'm trying to find a workaround to use variadic templates within c++03.
What I would like to achieve is - within a templated class - instanciated a boost::tuple
attribute, which would be composed of a vector for each single class template parameter.
This is how it would look like using c++11 variadic templates:
template<typename ...Parameters>
class Foo
{
typedef std::tuple<std::vector<Parameters>...> Vectors_t;
Vectors_t _vectorsTuple;
}
I would like to achieve the same using boost::tuple and boost::mpl or whatever other possible ways.
Thanks
UPDATE
This is the final solution I came up with. Partly based on @stefanmoosbrugger proposition.
template<class TypesList>
class FooImpl
{
typedef TypesList TypesList_t;
typedef typename boost::mpl::transform <
TypesList_t,
std::vector<boost::mpl::_1>
>::type VectorTypesList_t;
typedef typename boost::mpl::reverse_fold<
VectorTypesList_t,
boost::tuples::null_type,
boost::tuples::cons<boost::mpl::_2, boost::mpl::_1>
>::type VectorsTuple_t;
protected:
VectorsTuple_t _vectorsTuple;
};
template<class Type1,
class Type2 = boost::mpl::na,
class Type3 = boost::mpl::na,
class Type4 = boost::mpl::na> /* Made it up to four possible types as an example */
class Foo : public FooImpl<boost::mpl::vector<Type1, Type2, Type3, Type4> >{};