Basically, if I have this string:
"abcd"
I want to end up with the equivalent of:
'abcd'
at compile time. I have tried using macros, preprocessor magic, and Microsoft's charize operator (#@), but none of them work correctly. The end result should allow me to do something like this:
template <long N> struct some_type {};
long whatever = STR_TO_MULTI_CHAR_LITERAL("abcd");
some_type<whatever> xyz;
Let us assume that we can forget about big/little endian for now, you could use a
constexprunionlikeIf we need to consider endian, it becomes more complex. Also size of
longcould be 8, not 4.Another thought, if
longis 32bit,char32_t char4b = U'\UAABBFFFF'is supported in C++11. But then you need figure out the map fromAto45(hex value ofA). Then castchar4btolong.