<< Home

Appendix A: Language Reference Tables

This appendix gathers compact reference tables that you can consult quickly while working. They summarize essential facts without long explanation. Earlier chapters give full detail; the tables here provide fast reminders during coding or review.

Keywords and reserved identifiers

C++ reserves a small core of keywords for language features and implementation needs. These names cannot be used for your own identifiers. Some are contextual and appear only in templates or special constructs. The list below reflects the common set from current C++ standards.

Core keywords

The following table lists the fundamental keywords that appear in code across the language’s main features. They map to control flow, declarations, types, and basic operators.

KeywordPurpose
autoType deduction for variables and return types
boolBoolean type
breakExit the nearest loop or switch
caseLabel in a switch statement
catchException handler block
charCharacter type
classUser defined class type
constRead only qualifier
continueSkip to the next loop iteration
decltypeInfer type from an expression
defaultDefault label in switch or defaulted functions
deleteDestroy a dynamically allocated object
doStart a do while loop
doubleDouble precision floating point
elseAlternative path in if statements
enumEnumeration type
explicitDisable implicit conversions
exportExpose module interfaces
externExternal linkage specifier
falseBoolean false literal
floatFloating point type
forFor loop construct
friendAccess control exception for classes
gotoJump to a label
ifConditional branching
inlineInline expansion hint
intInteger type
longLong integer type
mutableAllow modification in const objects
namespaceLogical grouping of declarations
newAllocate objects dynamically
noexceptDeclare non throwing functions
nullptrNull pointer literal
operatorDefine overloaded operators
privatePrivate access level
protectedProtected access level
publicPublic access level
returnReturn from a function
shortShort integer type
signedSigned integer qualifier
sizeofSize of an expression or type
staticStatic storage or linkage
structStructure type
switchMulti way branching
templateDefine templates
thisPointer to current object
throwRaise an exception
trueBoolean true literal
tryStart a guarded block for exceptions
typedefAlias a type
typenameType placeholder in templates
unionStorage overlay type
unsignedUnsigned integer qualifier
usingIntroduce names or type aliases
virtualDeclare virtual functions
voidEmpty type
volatilePrevent certain optimizations
whileLoop while a condition holds
💡 Reserved identifiers include any name beginning with an underscore followed by a capital letter or two consecutive underscores. Avoid them entirely to keep code portable.

Operator precedence and associativity

Operator precedence determines how expressions bind when parentheses are absent. Associativity resolves ties at the same level. When expressions become dense, add parentheses for clarity even when precedence rules cover the case.

Precedence table

The following table shows a compact precedence ladder. Rows near the top bind more tightly than rows near the bottom. The associativity column explains the direction rules when operators share a level.

OperatorsAssociativity
::Left to right
++ -- () [] . ->Left to right
! ~ + - * & sizeof noexcept new deleteRight to left
* / %Left to right
+ -Left to right
<< >>Left to right
< <= > >=Left to right
== !=Left to right
&Left to right
^Left to right
|Left to right
&&Left to right
||Left to right
?:Right to left
= += -= *= /= %= &= |= ^= <<= >>=Right to left
,Left to right
⚠️ Operator overloading does not change precedence or associativity. Overloaded operators follow the same rules as their built in versions.

Numeric limits and sizes

The exact sizes of integer and floating point types vary by platform, but common implementations follow patterns. The table provides typical values from platforms that use 8 bit bytes and two’s complement integers. Always confirm with std::numeric_limits<T> at compile time if your code depends on exact ranges.

Common sizes

The table shows representative bit widths and ranges, not strict guarantees. Your platform may differ.

TypeTypical bitsApproximate range
char80 to 255 or -128 to 127
short16-32768 to 32767
int32-2 billion to 2 billion
long32 or 64Platform dependent
long long64About -9e18 to 9e18
float32Approx 1e-38 to 1e38
double64Approx 1e-308 to 1e308
long double64 to 128Platform dependent
std::size_t32 or 64Non negative, depends on pointer size
std::ptrdiff_t32 or 64Signed difference type
💡 Use fixed width types such as std::uint32_t or std::int64_t when exact sizes matter, for example in serialization formats.

Compiler flag crib sheet

Compilers offer flags that control standards, warnings, optimization, sanitizers, and debugging. The tables here list commonly used flags for GCC, Clang, and MSVC. Exact spellings may vary slightly by version.

Language and warnings

Choose a standard version explicitly and enable strong warnings during development. These flags help catch mistakes before runtime.

CompilerFlags
GCC-std=c++23, -Wall, -Wextra, -Wpedantic
Clang-std=c++23, -Wall, -Wextra, -Wpedantic
MSVC/std:c++23, /W4, /permissive-

Optimization and debugging

Switch between optimization levels depending on context. Fast builds use no optimization; release builds use higher levels. Include debugging information during development.

CompilerFlags
GCC-O0, -O2, -O3, -g
Clang-O0, -O2, -O3, -g
MSVC/Od, /O2, /Zi

Sanitizers

Sanitizers catch memory errors, undefined behavior, and threading races. Use them in CI and during development to prevent subtle bugs from reaching production.

PurposeFlags
Address checks-fsanitize=address
Undefined behavior-fsanitize=undefined
Thread safety-fsanitize=thread
Leak detection-fsanitize=leak
⚠️ MSVC does not support the same sanitizers as GCC and Clang. For Windows builds, combine static analysis, runtime checks, and third party tools to achieve similar coverage.