13
votes

Hi in boost mpl documentation I have discovered mpl::string and the following example:

typedef mpl::string<'hell','o wo','rld'> hello;

I'm a little bit surprised because I thought that in C or C++ we can't have more than one character between the character ' ?

Is it normal and valid ?

1
Just ab FYI. This (cpp-next.com/archive/2012/10/…) article has a better solution if you have c++11 available. - KitsuneYMG
That link is now dead :( - Sam Kellett

1 Answers

11
votes

Yes, it is valid C++. From any existing C++ standard, section [lex.conn]:

An ordinary character literal that contains more than one c-char is a multicharacter literal. A multicharacter literal has type int and implementation-defined value.