for
do-while
inline
noexcept
throw
try
catch
const
volatile
typedef
new
delete
this
friend
override
final
This is a reference of the core C++ language constructs.
Basic concepts
Comments ASCII chart Punctuation Names and identifiers Types – Fundamental types Object – Scope – Lifetime Definitions and ODR Name lookup qualified – unqualified (ADL) As-if rule Undefined behavior Memory model and data races Character sets and encodings Phases of translation The main function Modules (C++20)
main
Keywords
Preprocessor
#if - #ifdef - #ifndef - #elif #elifdef - #elifndef (C++23) #define - # - ## #include - #pragma #line - #error
#if
#ifdef
#ifndef
#elif
#elifdef
#elifndef
#define
#
##
#include
#pragma
#line
#error
Expressions
Value categories Evaluation order and sequencing Constant expressions Operators assignment – arithmetic increment and decrement logical – comparison member access and indirection call, comma, ternary sizeof – alignof (C++11) new – delete – typeid Operator overloading Default comparisons (C++20) Operator precedence Conversions implicit – explicit – user-defined static_cast – dynamic_cast const_cast – reinterpret_cast Literals boolean – integer – floating character – string nullptr (C++11) user-defined (C++11)
sizeof
alignof
typeid
static_cast
dynamic_cast
const_cast
reinterpret_cast
nullptr
Declarations
Namespace declaration Namespace alias References – Pointers – Arrays Structured bindings (C++17) Enumerations and enumerators Storage duration and linkage Translation-unit-local (C++20) Language linkage inline specifier Inline assembly const/volatile – constexpr (C++11) consteval (C++20) – constinit (C++20) decltype (C++11) – auto (C++11) typedef – Type alias (C++11) Elaborated type specifiers Attributes (C++11) – alignas (C++11) static_assert (C++11)
constexpr
consteval
constinit
decltype
auto
alignas
static_assert
Initialization
Default initialization Value initialization Copy initialization Direct initialization Aggregate initialization List initialization (C++11) Reference initialization Static non-local initialization zero – constant Dynamic non-local initialization ordered – unordered Copy elision
Functions
Function declaration Default arguments Variadic arguments Lambda expression (C++11) Argument-dependent lookup Overload resolution Operator overloading Address of an overload set Coroutines (C++20)
Statements
if – switch for – range-for (C++11) while – do-while continue – break – goto – return synchronized and atomic (TM TS)
if
switch
while
do
continue
break
goto
return
synchronized
atomic
Classes
Class types – Union types injected-class-name Data members – Bit fields Member functions – The this pointer Static members – Nested classes Derived class – using-declaration Empty base optimization Virtual function – Abstract class override (C++11) – final (C++11) Member access – friend Constructors and member initializer lists Default constructor – Destructor Copy constructor – Copy assignment Move constructor (C++11) Move assignment (C++11) Converting constructor – explicit specifier
using
explicit
Templates
Template parameters and arguments Class template – Function template Variable template (C++14) Class member template Template argument deduction Class template argument deduction (C++17) Explicit specialization – Partial specialization Parameter packs (C++11) – sizeof... (C++11) Fold-expressions (C++17) Dependent names – SFINAE Constraints and concepts (C++20) Requires expression (C++20)
sizeof...
Exceptions
throw-expression try-catch block function-try-block noexcept specifier (C++11) noexcept operator (C++11) Dynamic exception specification (until C++17)
Miscellaneous
History of C++ Extending the namespace std Acronyms
Idioms
Resource acquisition is initialization Rule of three/five/zero Pointer to implementation Zero-overhead principle