Boost logo

Boost :

Subject: Re: [boost] [preprocessor] pp-strings
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-06-27 17:34:07


On 06/27/2011 03:39 PM, lcaminiti wrote:

> NOTE: This is more a curiosity than anything else because I don't actually
> have a real use case for these spaced-strings. I researched them because
> there was a request for a macro like:
>
> STRING_TO_TYPE( MyType ) // expand to: typedef
> mpl::string<'M','y','T','y','p','e'> MyType_id_t;
> http://boost.2283326.n4.nabble.com/mpl-string-to-type-conversion-td2668494.html#a2668497
>
> As far as I know, such a macro cannot be implemented but both the following
> macros can be done (and I'd prefer somewhat (1) over (2)):
>
> SP_STRING_TO_TYPE( M y T y p e ) // (1)
> SEQ_STRING_TO_TYPE( (M)(y)(T)(y)(p)(e) ) // (2)

FYI, You can do STRING_TO_TYPE("MyType") or STRING_TO_TYPE(MyType) in
C++0x by expanding it to "MyType"[0], "MyType"[1] etc.


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