The rules (which did not changeare still unchanged in C++11C++23):
- Reserved in any scope, including for use as implementation macros:
- identifiers beginning with an underscore followed immediately by an uppercase letter
- identifiers containing adjacent underscores (or "double underscore")
- Reserved in the global namespace:
- identifiers beginning with an underscore
- Also, everything in the
stdnamespace is reserved. (You are allowed to add template specializations, though.) - User-defined literal suffix identifiers must start with an underscore (since C++11) and must not contain double underscore (reserved since C++23)
From the 2003 C++ Standard (appears in section 5.10.3 Identifiers [lex.name] since C++17):
17.4.3.1.2 Global names [lib.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.11) 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.165
165) Such names are also reserved in namespace
::std(17.4.3.1).
From the 2023 C++ Standard:
16.4.5.3.6 User-defined literal suffixes [usrlit.suffix]
Literal suffix identifiers ([over.literal]) that do not start with an underscore are reserved for future standardization.
Literal suffix identifiers that contain a double underscore __ are reserved for use by C++ implementations.