- Introduction and overview
- ABI and implementation
- Keywords
- Attributes
- Declarations
- Initialization
- Dynamic memory
- Exceptions
- Expressions
- Flow control
- Functions and function objects
- Operators
- Types
- Standards
- Tricks and subtleties
- C, C vs C++
🔗
- K.Henney. C++ – an invisible foundation of everything – Overload 161 (2021)
❔
- The definitive C++ book guide and list – Stack Overflow
🎥
- W.E.Brown. What I think when I think about C++ – Core C++ (2022)
- V.Ciura. C++ mythbusters – Meeting C++ (2022)
- H.Sutter. Quantifying accidental complexity: An empirical look at teaching and using C++ – CppCon (2020)
- C.Carruth, T.Winters. What is C++ – CppCon (2019)
⚓
- Standard C++
- The C++ standards committee
- C++ standards committee papers
- C++ standard core language closed issues
- C++ standard draft sources
- C.Carruth et al. Goals and priorities for C++ – WG21/P2137
❔
- Undefined, unspecified and implementation-defined behavior – Stack Overflow
🎥
- B.Steagall. Back to basics: The abstract machine – CppCon (2020)
🔗
- Binary compatibility issues with C++ – KDE wiki
- ABI stability – Android Open Source Project
- The ABI generic analysis and instrumentation library
🎥
- M.Clow. What is an ABI, and why is breaking it a problem? – C++Now (2021)
- M.Clow. What is an ABI, and why is breaking it bad? – CppCon (2020)
- L.Dionne. The C++ ABI from the ground up – CppCon (2019)
⚓
- T.Winters. What is ABI, and what should WG21 do about it? – WG21/P2028
- T.Winters. ABI – Now or never – WG21/P1863
- L.Dionne. Controlling the instantiation of vtables and RTTI – WG21/P1263
The Itanium C++ ABI is an ABI for C++. As an ABI, it gives precise rules for implementing the language, ensuring that separately-compiled parts of a program can successfully interoperate. It is not platform-specific and can be layered portably on top of an arbitrary C ABI. It is used as the standard C++ ABI for many major operating systems on all major architectures, and is implemented in many major C++ compilers, including GCC and Clang.
🔗
🔗
- R.Orr. Windows 64-bit calling conventions – Overload 120 (2014)
🔗
- D.Saks. Stepping up to C++: How virtual functions work – C/C++ Users Journal 12 (1994)
❔
- Virtual table layout of multiple inheritance – Stack Overflow
📖
- Ch. 1: Inheritance, Sec.: Inheritance implementation; Ch. 2: Multiple inheritance, Sec.: Multiple inheritance implementation – N.Llopis. C++ for game programmers – Charles River Media (2003)
See also Exceptions – Patterns, idioms, and design principles.
🔗
- V.Kochhar. How a C++ compiler implements exception handling (2002)
🎥
- A.Weis. Exceptions demystified – C++Now (2019)
- J.McNellis. Unwinding the stack: Exploring how C++ exceptions work on windows – CppCon (2018)
- D.Watson. C++ exceptions and stack unwinding – CppCon (2017)
⚓
🔗
- H.Sutter. Keywords that aren’t (or, comments by another name) – Dr.Dobb’s Journal (2003)
❔
- In a lambda, what does the second list of attributes do? – Stack Overflow
🎥
- B.Saks. Better code with C++ attributes – CppCon (2019)
See also Unused variables and return values – Patterns, idioms, and design principles.
These attributes allow the compiler to optimize for the case where paths of execution are more or less likely than any alternative path of execution.
See [[likely]]
/ [[unlikely]]
attributes – Hardware, optimization, and OS internals.
This attribute encourages the compiler to issue a warning if the return value is discarded. Conservative approach suggested by N.Josuttis:
- Should be added:
- existing APIs: not using the return value always is a “huge mistake”; not using the return value is a source of trouble and easily can happen;
- new APIs: not using the return value is usually an error.
- Should not be added:
- existing APIs: not using the return value is a possible/common way of programming at least for some input; not using the return value makes no sense but doesn’t hurt.
🔗
- What’s the reason for not using C++17’s
[[nodiscard]]
almost everywhere in new code? – Software Engineering
⚓
- N.Josuttis.
[[nodiscard]]
in the library – WG21/P0600
This attribute indicates that the function does not return.
🔗
- A.O’Dwyer.
void
versus[[noreturn]]
(2022)
❔
- What is the point of
[[noreturn]]
? – Stack Overflow
⚓
- C++ attribute:
noreturn
– C++ reference
This attribute specifies that the relocation operation for an object is trivial: moving the object and then immediately destroying the original is equivalent to
memcpy
. This attribute is not yet in the standard.
See Relocation – Memory – Optimization and hardware.
🔗
- D.Saks. The column that needs a name: Understanding C++ declarations – C/C++ Users Journal 14 (1996)
- D.Anderson. The “clockwise/spiral rule”
- T.Parr. How to read C declarations
- C gibberish <-> English
🎥
- W.E.Brown. A medley of C++: The principle behind C++ declaration syntax – C++ on Sea (2022)
- H.Hinnant. How to initialize
x
from expressiony
– Meeting C++ (2019) - D.Saks. East
const
butconstexpr
West – code::dive (2018)
See also Layout – Class types.
⚓
alignas
specifier – C++ reference
For variables, specifies that the type of the variable will be automatically deduced from its initializer. For functions, specifies that the return type will be deduced from its
return
statements. For non-type template parameters, specifies that the type will be deduced from the argument.
🔗
- H.Sutter. GotW #92:
auto
variables, Part 1 (2013) - H.Sutter. GotW #93:
auto
variables, Part 2 (2013) - H.Sutter. GotW #94: AAA style (almost always
auto
) (2013) - R.Orr.
auto
– A necessary evil? (Part II) – Overload 116 (2013) - R.Orr.
auto
– A necessary evil? – Overload 115 (2013)
❔
- C++11 – declaring non-static data members as
auto
– Stack Overflow - Does
auto
make C++ code harder to understand? – Software Engineering
In C++98:
const
means “logicallyconst
”, in C++11const
means “thread safe” (bitwiseconst
or internally synchronized). In C++98:mutable
means “not observably non-const
”, in C++11mutable
means “thread safe” (bitwiseconst
or internally synchronized).
🔗
- Const correctness – C++ FAQ
- H.Sutter. GotW #6: Const-correctness
- A.O’Dwyer.
const
is a contract (2019) - S.Meyers. Appearing and disappearing
const
s in C++ (2011) - D.Saks. Stepping up to C++: Mutable class members – C/C++ Users Journal 13 (1995)
❔
- Use of
const
for function parameters – Stack Overflow - C++
const
keyword – use liberally? – Stack Overflow
🎥
- H.Sutter. You don’t know
const
andmutable
– C++ and Beyond (2012)
⚓
- ES.28: Use lambdas for complex initialization, especially of
const
variables – C++ core guidelines
🔗
- J.Müller.
constexpr
is a platform (2020) - B.Revzin. The
constexpr
array size problem (2020) - A.Krzemieński.
constexpr
function is notconst
(2013)
❔
- Why is a
constexpr
function on a reference notconstexpr
? – Stack Overflow - Why do we need to mark functions as
constexpr
? – Stack Overflow - Detecting
constexpr
with SFINAE – Stack Overflow - Should I mark a compiler-generated constructor as
constexpr
? – Stack Overflow - Why disallow
goto
inconstexpr
functions? – Stack Overflow - The value of a
const
variable is or is not usable in a constant expression, depending on the variable type – Stack Overflow - Can you call a
static constexpr
member function at compile time? – Stack Overflow
🎥
- S.Schurr.
constexpr
: Introduction, Applications – CppCon (2015)
⚓
- B.Revzin. Using unknown pointers and references in constant expressions – WG21/P2280
❔
- C++20
constexpr
vector
andstring
not working – Stack Overflow
❔
- Will
consteval
functions allow template parameters dependent on function arguments? – Stack Overflow
The
decltype
specifier inspects the declared type of an entity or the type and value category of an expression.std::declval
converts any typeT
to a reference type, making it possible to use member functions in the operand of the decltype specifier without the need to go through constructors.
🔗
- A.O’Dwyer.
decltype
of a non-static member (2021)
❔
- Why does
std::declval
add a reference? – Stack Overflow
⚓
decltype
specifier – C++ reference
🔗
- S.Dargo. Bitwise enumerations (2022)
- A.Williams. Using
enum class
es as bitfields (2015)
❔
- Is it safe to
reinterpret_cast
anenum class
variable to a reference of the underlying type? – Stack Overflow - Using
reinterpret_cast
on an enum class – valid or undefined behavior? – Stack Overflow - Are C++ enums signed or unsigned? – Stack Overflow
⚓
- Enumeration declaration – C++ reference
- What is the type of an enumeration such as
enum Color
? Is it of typeint
? – C++ FAQ - If an enumeration type is distinct from any other type, what good is it? What can you do with it? – C++ FAQ
🎥
- D.Saks. Making new friends – CppCon (2018)
See Friend function templates – Function templates – Templates.
Hidden friends
🔗
- A.Williams. The power of hidden friends in C++ (2019)
🎥
- P.Bindels. Crouching tiger, hidden friend – ACCU (2023)
⚓
- W.E.Brown, D.Sunderland. Recommendations for specifying “hidden friends” – WG21/P1601
🔗
- P.Arias. Inline variables and functions (2019)
❔
- One Definition Rule – multiple definition of
inline
functions – Stack Overflow - Does it make any sense to use
inline
keyword with templates? – Stack Overflow
⚓
inline
specifier – C++ reference
❔
- Static variables in an inlined function – Stack Overflow
- What is a
static
function in C? – Stack Overflow
⚓
static_assert
declaration – C++ reference- B.Revzin. Allowing
static_assert(false)
– WG21/P2593
🔗
- S.Dargo. The 4 use of
using
in C++ (2022)
❔
- A
using
statement compiles with g++, fails compilation with clang – Stack Overflow - About the ambiguity of
using
a name vsusing
a namespace when doing unqualified calls – Stack Overflow
⚓
- Using-enum-declaration – C++ reference
- G.Ažman, J.Müller. Using enum – WG21/P1099
⚓
- Elaborated type specifier – C++ reference
🔗
- Flexible array member – Wikipedia
❔
- Are flexible array members valid in C++? – Stack Overflow
- Is using flexible array members in C bad practice? – Stack Overflow
There is an ambiguity in the grammar involving expression-statements and declarations: An expression-statement with a function-style explicit type conversion as its leftmost subexpression can be indistinguishable from a declaration where the first declarator starts with a
(
. In those cases the statement is a declaration.
🔗
- H.Sutter. GotW #75: Istream initialization?
- D.Kalev. Overcoming the “most vexing parse” problem (2009)
📖
- Item 6: Be alert for C++’s most vexing parse – S.Meyers. Effective STL: 50 Specific ways to improve your use of the standard template library – Addison-Wesley (2001)
⚓
- [stmt.ambig] Statements: Ambiguity resolution – C++ standard draft
🔗
- A.Fertig.
static
,inline
, or an unnamed namespace what’s the difference (2023)
❔
- Wherefore inline unnamed namespaces? – Stack Overflow
⚓
- Namespaces – C++ reference
🔗
- A.Fertig.
static
,inline
, or an unnamed namespace what’s the difference (2023) - What is external linkage and internal linkage? – Stack Overflow
- P.Goldsborough. Internal and external linkage in C++ (2016)
- J.Schilling. Extern inlines by default (2001)
🎥
- D.Saks. Storage duration and linkage in C and C++ – NDC TechTown (2019)
⚓
- Storage class specifiers – C++ reference
🔗
- S.Brand. Adding C++17 structured bindings support to your classes (2016)
❔
- Understand structured binding in C++17 by analogy – Stack Overflow
- Why are structured bindings defined in terms of a uniquely named variable? – Stack Overflow
- Structured bindings and tuple of references – Stack Overflow
⚓
- Structured binding declaration – C++ reference
- B.Revzin, J.Wakely. Structured bindings can introduce a pack – WG21/P1061
- N.Lesser. Extending structured bindings to be more like variable declarations – WG21/P1091
🔗
- A.O’Dwyer. PSA: Value-initialization is not merely default-construction (2023)
- P.Arias. Initialization of static variables (2020)
- C.McClure. C++ object initialization
- B.Filipek. What happens to your static variables at the start of the program? (2018)
- S.Brand. Initialization in C++ is bonkers – Overload 139, 9 (2017)
- E.Martin. Static initializers (2011)
- A.Demin. The difference between
new T()
andnew T
(in Russian, 2009)
❔
- Is C++11 uniform initialization a replacement for the old style syntax? – Software Engineering
- Can
T t = {};
andT t{};
produce different results? – Stack Overflow
⚓
- Initialization – C++ reference
🔗
- A.Fertig. Aggregates: C++17 vs. C++20 (2024)
❔
- What are aggregates and PODs and how/why are they special? – Stack Overflow
⚓
- Aggregate initialization – C++ reference
🔗
- A.Fertig. Evaluation order in C++ and uniform initialization (2023)
❔
- What is
constinit
in C++20? – Stack Overflow
🔗
- D.Saks. C++ theory and practice:
new
anddelete
– C/C++ Users Journal 15 (1997)
❔
- How do compilers use “over-allocation” to remember the number of elements in an allocated array? – C++ FAQ
- How do compilers use an “associative array” to remember the number of elements in an allocated array? – C++ FAQ
- Treating memory returned by operator
new(sizeof(T) * N)
as an array – Stack Overflow - Why should C++ programmers minimize use of
new
? – Stack Overflow - Difference between
new
andoperator new
? – Stack Overflow
📖
- Sec. 19.2.5: Allocation and deallocation – B.Stroustrup. The C++ programming language – Addison-Wesley (2013)
- Item 8: Understand the different meanings of
new
anddelete
– S.Meyers. More effective C++: 35 new ways to improve your programs and designs – Addison-Wesley (1996) - Ch. 10: Memory management – B.Stroustrup. The design and evolution of C++ – Addison-Wesley (1994)
⚓
- Low level memory management – C++ reference
- R.10: Avoid
malloc()
andfree()
– C++ core guidelines - R.11: Avoid calling
new
anddelete
explicitly – C++ core guidelines
🔗
- B.Filipek. New
new()
: The C++17’s alignment parameter foroperator new()
(2019)
⚓
- C.Nelson. Dynamic memory allocation for over-aligned data – WG21/P0035
See also Uninitialized storage – The standard library and proposals.
❔
- Array placement-new requires unspecified overhead in the buffer? – Stack Overflow
- Is using
malloc
forint
undefined behavior until C++20 – Stack Overflow
🎥
- C.J.Johnson. How to hold a
T
– CppCon (2019)
⚓
- R.Smith. Implicit creation of objects for low-level object manipulation – WG21/P0593
- B.Hutchings. Determining the buffer size for placement new – WG21/CWG issue 476 (2004)
- T.Koeppe. C++ DR about global placement array new – WG21/EWG issue 68 (2013)
❔
- How to properly replace global
new
anddelete
operators – Stack Overflow - Is it possible to replace the global
operator new
everywhere? – Stack Overflow
⚓
operator new
,operator new[]
: Global_replacements – C++ reference
See also Exceptions – Patterns, idioms, and design principles and Exceptions – The standard library and proposals.
🔗
- R.McArdell. C++11 (and beyond) exception support – Overload 141 (2017)
❔
- B.Stroustrup. Why doesn’t C++ provide a
finally
construct? – C++ style and technique FAQ - Is there any difference between
noexcept
and empty throw specification for an lambda expression? – Stack Overflow - Losing exception type when rethrowing an exception from a
catch
block – Stack Overflow
Specifies whether a function could throw exceptions.
⚓
noexcept
specifier – C++ reference
The keyword
nullptr
denotes the pointer literal. It is a prvalue of typestd::nullptr_t
.
See std::nullptr_t
– The standard library and proposals.
A compound literal constructs an unnamed object of specified type in-place:
( type ) { initializer-list }
.
🔗
- R.Meyers. The new C: Compound literals – Dr.Dobb’s Journal (2001)
❔
- Are compound literals standard C++? – Stack Overflow
⚓
- Compound literals – C++ reference
A user-defined literal (UDL) allows integer, floating-point, character, and string literals to produce objects of user-defined type by defining a user-defined suffix.
🔗
- A.O’Dwyer. Namespaces for UDLs (2018)
⚓
- User-defined literals – C++ reference
❔
- Who defines C operator precedence and associativity, and how does it relate to order of evaluation? – Stack Overflow
- What is the relation between operator precedence and order of evaluation? – Stack Overflow
⚓
- C++ operator precedence – C++ reference
🔗
- E.Lippert. Precedence vs associativity vs order (2008)
- P.Becker. Questions & Answers – C/C++ Users Journal 16 (1998)
❔
- What is the relation between operator precedence and order of evaluation? – Stack Overflow
- Who defines C operator precedence and associativity, and how does it relate to order of evaluation? – Stack Overflow
- Undefined behavior and sequence points – Stack Overflow
📖
- T.Cargill. A dynamic vector is harder than it looks – S.B.Lippman. C++ gems: Programming pearls from The C++ report (1997)
⚓
- Order of evaluation – C++ reference
❔
📖
- Item 2: Prefer C++-style casts – S.Meyers. More effective C++: 35 new ways to improve your programs and designs – Addison-Wesley (1996)
🔗
- A.O’Dwyer. Classically polymorphic visit replaces some uses of
dynamic_cast
(2020)
❔
- C++ equivalent of Java’s
instanceof
– Stack Overflow dynamic_cast
with RTTI disabled – Stack Overflow
🎥
- A.O’Dwyer.
dynamic_cast
from scratch – CppCon (2017)
⚓
dynamic_cast
conversion – C++ reference
📝
- Since C++20, some of type punning can be done using
std::bit_cast
, seestd::bit_cast
– The standard library and Boost.
🔗
- M.Sebor. The joys and perils of C and C++ aliasing. Part 1, Part II (2020)
- L.Torvalds. ... What’s the real reason for avoiding union aliasing? – Linux kernel mailing list (2018)
- S.Yaghmour. What is the strict aliasing rule and why do we care? (2018)
- M.Acton. Understanding strict aliasing (2006)
❔
- gcc, strict-aliasing, and horror stories – Stack Overflow
- What is the strict aliasing rule? – Stack Overflow
- Performance benefits of strict aliasing – Stack Overflow
- Gcc, strict-aliasing, and casting through a union – Stack Overflow
- Can I safely convert struct of floats into float array in C++? – Stack Overflow
- Reinterpret struct with members of the same type as an array in a standard compliant way – Stack Overflow
🎥
- T.Doumler. (How not to do) Type punning in modern C++ – CppCon (2019)
⚓
- Type punning – Wikipedia
- Options that control optimization: Type punning – GCC documentation
🔗
- A.S.Knatten. lvalues, rvalues, glvalues, prvalues, xvalues, help! – Overload 150 (2019)
- B.Revzin. Value categories in C++17 (2017)
❔
- What categories (lvalue, rvalue, xvalue, etc.) can expressions that produce temporaries of class type fall into? – Stack Overflow
- Rvalues, lvalues and formal definitions – Stack Overflow
🎥
- W.E.Brown. A medley of C++: Exploring C++ value categories and the expression category taxonomy – C++ on Sea (2022)
⚓
- Value categories – C++ reference
- B.Stroustrup. “New” value terminology
🔗
- S.Dargo. The infamous bug of range-based for loops (2022)
- M.Clow. Range based for loops and pairs of iterators (2013)
🎥
- D.Kühl. Range
for
– CppCon (2016)
⚓
if
statement – C++ reference
❔
- Difference between
if constexpr()
vsif()
– Stack Overflow
Transfers control to one of several statements, depending on the value of a condition.
🎥
- H.Wennborg. C++
switch
statements under the hood in LLVM – StockholmCpp (2024)
⚓
switch
statement - C++ reference
❔
- Simplest way to determine return type of function – Stack Overflow
- C++
decltype
deducing current function returned type – Stack Overflow
🎥
- B.Saks. Back to basics: Function call resolution in C++ – CppCon (2024)
- M.Shah. Back to basics: Functions in C++ – CppCon (2023)
🔗
🔗
- What is “argument-dependent lookup” (aka ADL, or “Koenig lookup”)? – Stack Overflow
- A.O’Dwyer. What is ADL? (2019)
- A.O’Dwyer. ADL insanity (2019)
- A.O’Dwyer. How
hana::type<T>
“disables ADL” (2019) - A.O’Dwyer. Avoid ADL calls to functions with common names (2018)
- A.O’Dwyer. WG21: Avoid creating ADL situations on functions with semi-common names (2018)
❔
- Why doesn’t ADL find function templates? – Stack Overflow
🎥
- J.Turner. Episode 160: Argument dependent lookup – C++ Weekly
⚓
- Argument-dependent lookup – C++ reference
- J.Spicer. ADL and function templates that are not visible – WG21/P0846
❔
- Move-only version of
std::function
– Stack Overflow - How to create an
std::function
from a move-capturing lambda expression? – Stack Overflow
⚓
std::function
– C++ reference
See also Lambda expression idioms – Patterns, idioms, and design principles.
🔗
- R.Chen. Non-capturing C++ lambdas can be converted to a pointer to function, but what about the calling convention? (2015)
- S.Meyers. C++14 lambdas and perfect forwarding (2013)
- S.Meyers. Lambdas vs. closures (2013)
- A.Allain. Lambda functions in C++11 – the definitive guide (2011)
❔
- What is the need of template lambda introduced in C++20 when C++14 already has generic lambda? – Stack Overflow
- What is a lambda expression in C++11? – Stack Overflow
- Why are lambda expressions not allowed in an unevaluated operands but allowed in the unevaluated portions of constant expressions? – Stack Overflow
- Can we get the type of a lambda argument? – Stack Overflow
- Why is a
const
variable sometimes not required to be captured in a lambda? – Stack Overflow - In a lambda, what does the second list of attributes do? – Stack Overflow
🎥
- W.E.Brown. A medley of C++: Why are they named lambdas? – C++ on Sea (2022)
- R.Orr. Let’s look at lambdas – ACCU (2021)
- B.Geller, A.Sermersheim. Back to basics: Lambda expressions – CppCon (2020)
- B.Deane. C++20 lambdas: Familiar template syntax – CppCon (2020)
- A.O’Dwyer. Back to basics: Lambdas from scratch – CppCon (2019)
⚓
- L.Dionne, H.Tong. Wording for lambdas in unevaluated contexts – WG21/P0315
- L.Dionne. Familiar template syntax for generic lambdas – WG21/P0428
🔗
- A.Fertig. Calling a C++ member function with a null object (2024)
- A.Fertig. The power of ref-qualifiers (2022)
- V.Lazarenko. Why C++ member function pointers are 16 bytes wide (2013)
- R.Chen. Pointers to member functions are very strange animals (2004)
- C.Skelly. Powerful pointers to member functions – C/C++ Users Journal 12 (1994)
⚓
- Pointers to member functions – C++ FAQ
🎥
- K.van Rens. Special member functions in C++ – C++ on Sea (2023)
🔗
If, instead of a function body, the special syntax
= delete;
is used, the function is defined as deleted. Any use of a deleted function is ill-formed (the program will not compile).
🔗
- A.O’Dwyer. Refactoring with
=delete
(2022) - A.O’Dwyer. What
=delete
means (2021) - A.Knatten. No move vs deleted move constructors – Overload 166 (2021)
- A.Knatten. The difference between no move constructor and a deleted move constructor (2021)
⚓
- Deleted functions – C++ reference
🔗
- E.Bendersky. How statically linked programs run on Linux (2012)
🎥
- M.Godbolt. The bits between the bits: How we get to
main()
– CppCon (2018)
⚓
- Main function – C++ reference
❔
- What are the basic rules and idioms for operator overloading? – Stack Overflow
🎥
- B.Deane. Operator overloading: History, principles and practice – CppCon (2018)
⚓
operator
overloading – C++ reference- Canonical implementations – C++ reference
🔗
- J.Müller. Mathematics behind comparison (2018)
⚓
- Comparison operators – C++ reference
🔗
- B.Revzin. Implementing the spaceship operator for
optional
– Overload 147 (2018)
🎥
- L.de Cock. Space invaders: The C++20 spaceship operator is upon us – ACCU (2023)
- W.E.Brown. A C++20 preview:
operator<=>
– CppCon (2017)
⚓
- Default comparisons – C++ reference
- D.Stone. I did not order this! Why is it on my bill? – WG21/P1190
🔗
- A.O’Dwyer. Pointer comparisons with
std::less<void>
: a horror story (2019) - K.Walfridsson. C pointers are not hardware pointers (2016)
⚓
- Pointer comparison operators – C++ reference
🔗
- K.Pugh. Using the conditional operator
?:
– C/C++ Users Journal 10 (1992)
🔗
⚓
- W.E.Brown. Implication for C++ – WG21/P2971
The
sizeof
operator yields the size in bytes of the object or type. When applied to a class type, the result is the size of an object of that class plus any additional padding required to place such object in an array. Thealignof
operator returns the alignment required for any instance of a type.
❔
⚓
sizeof
operator – C++ referencealignof
operator – C++ reference
❔
- What are the 15 classifications of types in C++? – Stack Overflow
🎥
- W.E.Brown. A medley of C++: The universe of C++ types – C++ on Sea (2022)
- B.Milewski. Why algebraic data types are important – code::dive (2018)
❔
- How much existing C++ code would break if
void
was actually defined asstruct void {};
– Stack Overflow
⚓
- Void type – C++ reference
🔗
- J.Müller. New integer types I’d like to see (2022)
- W.Dietz et al. Understanding integer overflow in C/C++ – Proc. ICSE (2012)
- Rule 04. Integers – SEI CERT C coding standard
❔
- Compiler optimizations may cause integer overflow. Is that okay? – Stack Overflow
- Why does integer overflow on x86 with GCC cause an infinite loop? – Stack Overflow
- Why does this loop produce “warning: iteration
3u
invokes undefined behavior” and output more than 4 lines? – Stack Overflow - Does a
long
ban make sense? – Software Engineering
🎥
- R.Seacord. Integer type selection in C++ in safe, secure and correct code – C++ Now (2023)
- J.Bastien. Signed integers are two’s complement – CppCon (2018)
- D.Saks. Choosing the right integer types in C and C++ – code::dive (2018)
⚓
- J.Bastien. Signed integers are two’s complement – WG21/P0907
❔
- Implicit type conversion rules in C++ operators – Stack Overflow
- Why do unsigned “small” integers promote to
signed int
? – Stack Overflow
⚓
- Integral promotion – C++ reference
🔗
There are three floating point types:
float
,double
, andlong double
. The typedouble
provides at least as much precision asfloat
, and the typelong double
provides at least as much precision asdouble
. The set of values of the typefloat
is a subset of the set of values of the typedouble
; the set of values of the typedouble
is a subset of the set of values of the typelong double
. The value representation of floating-point types is implementation-defined.
See also Floating-point arithmetic – Numeric data structures and algorithms.
🔗
- D.Howard. Byte swapping floating point types (2007)
- Semantics of floating point math in GCC – GCC Wiki
- *Compiler options:
/fp
(specify floating-point behavior) – Visual C++ documentation - Handling overflow when casting doubles to integers in C – Stack Overflow
❔
- When do you use
float
and when do you usedouble
– Software Engineering
⚓
- P.A.Bristow, C.Kormanyos, J.Maddock. Floating-point typedefs having specified widths – WG14/N1703
- P.A.Bristow, C.Kormanyos, J.Maddock. Floating-point typedefs having specified widths – WG21/N3626
🔗
long double
(GCC specific) and__float128
– Stack Overflow- How to use GCC 4.6.0 libquadmath and
__float128
on x86 and x86_64 – Stack Overflow
⚓
- Additional floating types – GCC documentation
🔗
- Trivial, standard-layout, POD, and literal types – Visual C++ language reference (2018)
- Trivial vs. standard layout vs. POD – Stack Overflow
❔
- Can C arrays contain padding in between elements? – Stack Overflow
- One-dimensional access to a multidimensional array: is it well-defined behaviour? – Stack Overflow
🎥
- B.Saks. Back to basics: Pointers and memory – CppCon (2020)
⚓
- Null pointers – C programming FAQs
❔
- Is C++ allowed to increase the derived class size if there are no new member variables compared to the base class? – Stack Overflow
🎥
- R.Powell. Intro to the C++ object model – CppCon (2015)
⚓
- Class declaration – C++ reference
🔗
- A.Fertig. When an empty destructor is required (2023)
- A.Fertig. Why you shouldn’t provide an empty destructor (2023)
⚓
- Destructors – C++ reference
🔗
- S.Dargo. Make declaration order layout mandated (2022)
- E.S.Raymond. The lost art of structure packing
- E.Bendersky. Dumping a C++ object’s memory layout with Clang (2012)
❔
- Structure padding and packing – Stack Overflow
- Passing reference of packed
struct
member to template – GCC bug? – Stack Overflow
🎥
- S.Dewhurst. Back to basics: Class layout – CppCon (2020)
⚓
- C++ named requirements:
StandardLayoutType
– C++ reference std::is_standard_layout
– C++ referencestd::has_unique_object_representations
– C++ reference- P.Balog. Make declaration order layout mandated – WG21/P1847
See Functions and function objects – Member functions.
See also Implementation of inheritance – ABI and implementation.
🔗
- S.Pamudurthy. Polymorphism in C++ – A type compatibility view – Overload 141 (2017)
- E.de Vries. Memory layout for multiple and virtual inheritance (2006)
❔
:movie_camera
- I.Bogosavljevic. The hidden performance price of C++ virtual functions – CppCon (2022)
📖
- Ch. 1: Inheritance, Ch. 2: Multiple inheritance – N.Llopis. C++ for game programmers – Charles River Media (2003)
❔
- B.Stroustrup. unions (generalized) – C++11 - the new ISO C++ standard
⚓
- Union declaration – C++ reference
⚓
- A.Meredith. Abominable function types – WG21/P0172
❔
- Is null reference possible? – Stack Overflow
🔗
- T.Winters. TotW #107: Reference lifetime extension` – Abseil C++ Tips (2015)
❔
- Does a
const
reference class member prolong the life of a temporary? – Stack Overflow
:movie_camera
- A.Schödl. The C++ rvalue lifetime disaster – CoreHard (2019)
⚓
- Lifetime of a temporary – C++ reference
See also Move semantics – Patterns, idioms, and design principles.
🔗
- R.Chen. On harmful overuse of
std::move
(2023) - A.O’Dwyer. Don’t
forward things
that aren’t forwarding references (2023) - C.DaCamara. Improving the state of debug performance in C++ (2022)
- J.Müller. Implementation сhallenge: Replacing
std::move
andstd::forward
(2020) - H.E.Hinnant et al. A brief introduction to rvalue references (2008)
- Rvalue reference declarator:
&&
– Microsoft Visual C++ (2016) - T.Becker. C++ rvalue references explained (2013)
- S.Meyers. C++14 lambdas and perfect forwarding (2013)
- S.Meyers. Universal references in C++11 (mirror) – Overload 111, 8 (2012)
- E.Bendersky. Understanding lvalues and rvalues in C and C++ (2011)
❔
- What is move semantics? – Stack Overflow
- Rvalues, lvalues and formal definitions – Stack Overflow
- Pass by value vs pass by rvalue reference – Stack Overflow
- Rvalues and move semantics with
return
statement – Stack Overflow - The implementation of
std::forward
– Stack Overflow - Advantages of using
forward
– Stack Overflow - Do rvalue references to
const
have any use? – Stack Overflow - What does
auto&&
tell us? – Stack Overflow
🎥
- A.Kirsh. To move or not to move: An interactive analysis – CppNorth (2023)
- N.Josuttis. The hidden secrets of move semantics – CppCon (2020)
- D.Olsen. Back to basics: Move semantics – CppCon (2020)
- K.Iglberger. Back to basics: Move semantics. Part I, Part II – CppCon (2019)
- A.Schödl. The C++ rvalue lifetime disaster – CoreHard (2019)
- N.Josuttis. The nightmare of move semantics for trivial classes – CppCon (2017)
⚓
- B.Stroustrup. “New” value terminology
See Opaque typedef – Patterns, idioms, and design principles.
❔
- B.Stroustrup. C++11 - the new ISO C++ standard
🔗
- M.Nelson. The C++14 standard: What you need to know – Dr.Dobb’s Journal (2014)
- A.Krzemieński.
constexpr
function is notconst
(2013)
🎥
- N.Josuttis. C++17 : The biggest traps – C++ on Sea (2019)
- N.Josuttis. C++17 – The best features - ACCU (2018)
- B.A.Lelbach. C++17 features. Part I, Part II – CppCon (2017)
- A.Meredith. C++17 in breadth (not depth). Part I, Part II – CppCon (2016)
⚓
- C++17 compiler support – C++ reference
🔗
- S.Dargo. My first work experience with C++20 (2022)
🎥
- A.Williams. An introduction to multithreading in C++20 – CppCon (2022)
- N.Josuttis. C++20: My favourite code examples – ACCU (2022)
- N.Josuttis. C++20: My favourite code examples – Meeting C++ (2021)
- B.Deane. C++20 lambdas: Familiar template syntax – CppCon (2020)
- F.Cooper. C++20: All the small things – C++ on Sea (2020)
- B.Stroustrup. C++20: C++ at 40 – CppCon (2019)
- A.Meredith. How C++20 can simplify
std::tuple
– ACCU (2019)
⚓
- Compiler support for C++20 – C++ reference
🔗
- A.O’Dwyer. Hidden
reinterpret_cast
s (2020)
❔
- Hidden features of C++ – Stack Overflow
- Why compilers test the least significant bit in an address? – Stack Overflow
- Why does the size of class in C++ depend on the
public
/private
status of data members? – Stack Overflow - Difference between
struct
andtypedef struct
in C++? – Stack Overflow - What are “extern char condition tricks”? – Stack Overflow
- Why can I use scalar type as the return type of
operator->
? – Stack Overflow - What is the worst real-world macros/pre-processor abuse you’ve ever come across? – Stack Overflow
🎥
- JF Bastien.
*(char*)0 = 0;
– C++ on Sea (2023) - J.Müller . C++ features you might not know – C++ on Sea (2023)
- M.Kruse.
v.~uint32_t();
– CppCon (2019) - J.Wakely, M.Clow. These 10 tricks that only library implementors know! – ACCU (2018)
🔗
- J.Schaub. Access to private members. That’s easy! (2010))
❔
- Accessing private members – Stack Overflow
🔗
- D.Weiler. incbin – Include binary files in C/C++
- H.Landau. Embedding of binary data into programs
❔
- Embedding resources in executable using GCC – Stack Overflow
⚓
- J. Meneide.
std::embed
– WG21/P1040
🔗
- A.Weissflog. Modern C for C++ peeps (2019)
- Linus Torvalds on C++ (2007)
- J.Nieminen. A response to Linus Torvalds on C++ (2007)
- D.R.Tribble. Incompatibilities between ISO C and ISO C++ (2001)
❔
- What are the fundamental differences between C and C++? – Software Engineering
- Why should we
typedef
astruct
so often in C? – Stack Overflow - Size of character (
'a'
) in C/C++ - Is there any reason to use C++ instead of C, Perl, Python, etc.? – Software Engineering
- When to use C over C++, and C++ over C? – Software Engineering
- Is the C programming language still used? – Software Engineering
🎥
- D.Zalewski. C is great, long live C! Programming in modern C with a sneak peek into C23 – ACCU (2023)
- L.Sas. Modern C and what we can learn from it – ACCU (2021)
⚓
📖
- Essay 1: You must be joking – P.J.Plauger. Programming on purpose III: Essays on software technology (1994)
🔗
- A.Mertz. Calling C code from C++ with
extern “C”
(2018)
❔
- Call a C function from C++ code – Stack Overflow
- What kinds of C++ functions can be placed in a C function pointer? – Stack Overflow
- Passing lambdas as callbacks to C functions – Stack Overflow
- How to make a function with C-linkage from template? – Stack Overflow
- What is the difference between
function()
andfunction(void)
? – Software Engineering
❔
- Difference between initialization of static variables in C and C++ – Stack Overflow
🔗
- P.Becker. Questions & Answers – C/C++ Users Journal 16 (1998)
❔
- Conditional operator differences between C and C++ – Stack Overflow