Boost logo

Boost :

Subject: Re: [boost] C++11 Metaprogramming
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-04-01 15:01:33

On 04/01/2012 06:36 PM, Eric Niebler wrote:
> On 3/31/2012 7:12 PM, Dave Abrahams wrote:
>> Hi All,
>> I am on the C++Now 2012 schedule giving a talk on metaprogramming in
>> C++11, which is really just supposed to be an overview of the state of
>> the art. I am just at the beginnings of my research for this
>> presentation, having learned a few things and done a few experiments,
>> and it seemed to me foolish not to ask the Boost community for its
>> insights. I'm sure y'all have come up with many neat tricks and
>> techniques. If you'd care to share them here, that would be much
>> appreciated.
> I recall a discussion about processing string literals at compile time
> using user-defined literals. Surely that counts.

Not sure if they didn't remove that feature in the end.

However, with constexpr you can just do

struct string;
#define CSTRING(s) string<BOOST_PP_ENUM(256, CSTRING_, s)>
#define CSTRING_(z,i,s) (i < strlen(s) ? s[i] : '\0')

CSTRING("foo") will expand to string<'f', 'o', 'o', '\0', '\0', ...>

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