C++ keywords
inline
specifier noexcept
specifier (C++11)typedef
declaration
This is a list of reserved keywords in C++. Since they are used by the language, these keywords are not available for re-definition or overloading. As an exception, they are not considered reserved in attributes (excluding attribute argument lists).(since C++11)
- (1) — meaning changed or new meaning added in C++11.
- (2) — new meaning added in C++14.
- (3) — meaning changed or new meaning added in C++17.
- (4) — meaning changed or new meaning added in C++20.
- (5) — new meaning added in C++23.
Note that: and
, bitor
, or
, xor
, compl
, bitand
, and_eq
, or_eq
, xor_eq
, not
and not_eq
(along with digraphs: <%, %>, <:, :>, %:, %:%: and trigraphs: ??<, ??>, ??(, ??), ??=, ??/, ??', ??!, ??-(until C++17)) provide an alternative way to represent standard tokens. These keywords are also considered reserved in attributes (excluding attribute argument lists), but some implementations handle them the same as the others.(since C++11)
In addition to keywords, there are identifiers with special meaning, which may be used as names of objects or functions, but have special meaning in certain contexts.
final
(C++11)
override
(C++11)
transaction_safe
(TM TS)
transaction_safe_dynamic
(TM TS)
import
(C++20)
module
(C++20)
pre
(C++26)
post
(C++26)
trivially_relocatable_if_eligible
(C++26)
replaceable_if_eligible
(C++26)
Also, all identifiers that contain a double underscore __
in any position and each identifier that begins with an underscore followed by an uppercase letter is always reserved, and all identifiers that begin with an underscore are reserved for use as names in the global namespace. See identifiers for more details.
The namespace std
is used to place names of the standard C++ library. See Extending namespace std for the rules about adding names to it.
The name posix
is reserved for a future top-level namespace. The behavior is undefined if a program declares or defines anything in that namespace.
The following tokens are recognized by the preprocessor when in context of a preprocessor directive:
ifdef
ifndef
elifdef (C++23)
elifndef (C++23)
define
undef
defined
__has_include (C++17)
__has_cpp_attribute (C++20)
__has_embed (C++26)
The following tokens are recognized by the preprocessor outside the context of a preprocessor directive:
_Pragma (C++11)