Boost logo

Boost :

Subject: [boost] [mpl] Can we generate this type in a simpler way?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-10-01 15:10:09


Hi,

I want to generate the following type

R1::mth1_<T1, R3::mth1_<T3, C::mth1_> > >

from mpl::vector<mpl::pair<R1, T1>, mpl::pair<R3, T3>, C and mth1_?

I have started with this
 
template <typename SequenceOfPairs, typename E, ??? MTH>
struct generator {
    typedef ??? type;
};

but I don't know what MTH'can be, because we have 3 different mth1_.

So I have reached to make a specific mth1_generator (for the specific symbol 'mth1_')

template <typename SequenceOfPairs, typename E>
struct mth1_generator {
    typedef ??? type; // The details of the type are ommited using 'mth1'
};

satisfying mth1_generate<mpl::vector<mpl::pair<R1, T1>, mpl::pair<R3, T3>, C>::type is equal to R1::mth1_<T1, R3::mth1_<T3, C::mth1_> > > ?

As aal the mthX_generator follow the same structure, I have defined a macro DEFINE_GENERATOR which will define the specific generator for a symbol MTH

#define DEFINE_GENERATOR(MTH) \
template <typename SequenceOfPairs, typename E>
struct MTH##_generator {
    typedef ??? type; // The details of the type are ommited suing now MTH.
}

So the user will just have to do

DEFINE_GENERATOR(mth1);

Can I do it in a simpler way using some kind of traits or this is an inherent preprocessor problem?

Thanks for clarifications,
_____________________
Vicente Juan Botet Escribá


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk