In C++11, we get user-defined literals. The C++ standard has examples of these, such as:
long double operator "" _w(long double);
And it says the literal should start with an underscore:
17.6.4.3.5 User-defined literal suffixes
Literal suffix identifiers that do not start with an underscore are reserved for future standardization.
However, there's another section in the standard that says
17.6.4.3.2 Global names
Certain sets of names and function signatures are always reserved to the implementation:
— Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.12) is reserved to the implementation for any use.
— Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
I'm looking to better understand exactly what 17.6.4.3.2 (Global names) says/means and how it relates to 17.6.4.3.5 (User-defined literal suffixes). Specifically:
- Does the second part of 17.6.4.3.2 (Global names) require user-defined literals (like the above
_w) to be defined in a namespace (that is, not in the global namespace)? If so, I wish the standard would've illustrated this. - I presume that the first part of 17.6.4.3.2 (Global names) rules out user-defined literals like
_W(followed by upper case) and__wand_w__(two consecutive underscores). Correct?
Edit:
As a follow up, there's a part of the standard that says:
13.5.8 User-defined literals
[...]
2 A declaration whose declarator-id is a literal-operator-id shall be a declaration of a namespace-scope function or function template (it could be a friend function (11.3)), an explicit