Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-04-29 02:56:10

Joaquín Mª López Muñoz wrote:

> Seems like a common enough problem, but I haven't been able to
> find any facility to construct a MPL Sequence conformant type from
> a boost::tuple. Has anybody run into the same problem? If so, pointers
> to info / snippets of code are most welcome.

Recently I implemented function_arguments<Signature> as MPL random access
sequence. I also implemented sig2tuple<Signature>. So, I'm able to create
an MPL sequence from function signature, then modify it (add, remove or
transform arguments) and then convert it into tuple. You can take a look at
code here:

1. Definition of function_arguments

2. Definition of sig2tuple and use of function_arguments

I recommend using function_arguments sequence only for types which are
function agruments. I can suggest that you need more then that. This is the
other way of doing it:

template<class Tuple>
struct tuple2vector;

// Less specialized first

template<class T1, class T2, class T3, ..., class T10>
struct tuple2vector< tuple<T1,T2,T3,...,T10> >
    typedef mpl::vector<T1,T2,T3,...,T10> type;

// ...

template<class T1, class T2>
struct tuple2vector< tuple<T1,T2> >
    typedef mpl::vector<T1,T2> type;

template<class T1>
struct tuple2vector< tuple<T1> >
    typedef mpl::vector<T1> type;

struct tuple2vector< tuple<> >
    typedef mpl::vector<> type;

Alternatively, you can implement MPL conformant sequence
tuple_sequence<Tuple>. It's not so hard as you can imagine.
(Question to MPL's authors: when it will be documented?).

Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

Boost list run by bdawes at, gregod at, cpdaniel at, john at