|
Boost : |
Subject: Re: [boost] [mpl] string to type conversion
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-18 22:22:25
2010/5/13 Bartosz Marcinkiewicz <bma_at_[hidden]>:
> Hello,
>
> I would like to have a macro which could be used like this:
>
> STRING_TO_TYPE( MyType )
>
> which would yield:
>
> typedef mpl::string<'M','y','T','y','p','e'> MyType_id_t;
>
> Any ideas how to implement something like that?
I also researched something similar about 1 year ago and concluded
that it is not possible (but I think CHAOS supports a string-type
preprocessor data structure which I did not investigate because it is
not available for all compilers).
This can be done instead if you are willing to wrap the single
characters between parenthesis:
STRING_TO_TYPE( (M)(y)(T)(y)(p)(e) )
If this would work for your application, I can post the code for this
macro (or just look at BOOST_PP_SEQ_FOLD_LEFT() or similar and program
it yourself). Let me know.
Regards,
-- Lorenzo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk