8.25 ? operator

A ? operator whose second and third operands are string literals or wide string literals can be implicitly converted to char * or wchar_t *.

In C++ string literals are const. There is an implicit conversion that enables conversion of a string literal to char * or wchar_t *, dropping the const. That conversion, however, applies only to simple string literals. Permitting it for the result of a ? operation is an extension.


char *p = x ? "abc" : "def";
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.