
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 template<BOOST_PP_ENUM_PARAMS(256, char BOOST_PP_INTERCEPT)> 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', ...>