Unary plus (+) against literal string

Unary + can be applied to arithmetic type values, unscoped enumeration values and pointer values because …

the C++ standard defines it that way, in C++11 §5.3.1/7.

In this case the string literal, which is of type array of char const, decays to pointer to char const.

It’s always a good idea to look at the documentation when one wonders about the functionality of something.


“The operand of the unary + operator shall have arithmetic, unscoped enumeration, or pointer type and the
result is the value of the argument. Integral promotion is performed on integral or enumeration operands.
The type of the result is the type of the promoted operand.”

Leave a Comment