writes:
Hi,
Is it possible to do this trick during compilation time?
I was able to go from type lists to boost::cons but I can't find a way to
make that last step.
Not sure what you mean by "that last step..."
namespace mpl = boost::mpl;
using namespace mpl::placeholders;
typedef mpl::vector types;
typedef mpl::fold >::type tuple_type;
tuple_type some_tuple;
If you want it to be a specialization of the boost::tuple template
(misguided, IMO) you can do it, but not "algorithmically." You need a
bunch of partial specializations:
template
struct types_to_tuple;
template <class V>
struct types_to_tuple
{
typedef boost::tuple<> type;
}
template <class V>
struct types_to_tuple
{
typedef boost::tuple::type> type;
}
template <class V>
struct types_to_tuple
{
typedef boost::tuple::type, typename mpl::at_n<1>::type> type;
}
etc.
This works on mpl::vector. Getting it to work on mpl::list is
slightly more complicated.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com