
I'm not sure it's possible to get a string literal in a template< char ...> class string; 'Literals transformation is redefined into two distinct phases: raw and cooked. A raw literal is a sequence of characters of some specific type, while the cooked literal is of a separate type. The C++ literal 1234, as a raw literal, is this sequence of characters '1', '2', '3', '4'. As a cooked literal, it is the integer 1234. The C++ literal 0xA in raw form is '0', 'x', 'A', while in cooked form it is the integer 10.
Literals can be extended in both raw and cooked forms, with the exception of string literals, which can only be processed in cooked form. This exception is due to the fact that strings have prefixes that affect the specific meaning and type of the characters in question.' - source: wikipedia - http://en.wikipedia.org/wiki/C%2B%2B11#User-defined_literals . Right below that Wikipedia describes a variadic template-based mechanism, where the compiler instantiates a template operator and
Hi Martin, passes the characters as template arguments to it. The return type of that operator could be an MPL list of boxed characters and we could access it using decltype - at least this is the idea. Your approach is different than ours, since it is based on constexpr while ours is based on template metaprogramming. I think it would be interesting to compare the two. Could you implement something like the type-safe printf using this approach? (Parsing the format string at compile-time, generate a list of expected types and type check the rest of the printf arguments.) Regards, Ábel