- Introduction and overview
- ABI
- Attributes
- Declarations
- Exceptions
- Expressions
- Functions
- Standards
- Structured bindings
- Tricks and subtleties
- Types
🔗
- The definitive C++ book guide and list – Stack Overflow
⚓
🎥
- M.Godbolt. The bits between the bits: How we get to
main()– CppCon (2018)
⚓
- Main function – C++ reference
🔗
- Binary compatibility issues with C++ – KDE wiki
- ABI stability – Android Open Source Project
🎥
- L.Dionne. The C++ ABI from the ground up – CppCon (2019)
⚓
- The ABI generic analysis and instrumentation library
- L.Dionne. Controlling the instantiation of vtables and RTTI – WG21/P1263R0 (2018)
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.
🔗
🎥
- B.Saks. Better code with C++ attributes – CppCon (2019)
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.
- Should be added:
🔗
- 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/P0600R0 (2017)
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.
📝
- In C++98:
constmeans “logicallyconst”, in C++11constmeans “thread safe” (bitwiseconstor internally synchronized). - In C++98:
mutablemeans “not observably non-const”, in C++11mutablemeans “thread safe” (bitwiseconstor internally synchronized).
🔗
- Const correctness – C++ FAQ
- H.Sutter. GotW #6: Const-correctness – Guru of the Week (2009)
- S.Meyers. Appearing and disappearing
consts in C++ (2011) - Use of
constfor function parameters – Stack Overflow - C++
constkeyword – use liberally? – Stack Overflow
🎥
- H.Sutter. You don’t know
constandmutable– C++ and Beyond (2012)
⚓
- ES.28: Use lambdas for complex initialization, especially of
constvariables – C++ Core Guidelines
🔗
- Why is a
constexprfunction on a reference notconstexpr? – Stack Overflow
🎥
- S.Schurr.
constexpr: Introduction, Applications – CppCon (2015)
See Friend function templates – Function templates – Templates.
Hidden friends
🔗
- A.Williams. The power of hidden friends in C++ (2019)
⚓
- Recommendations for specifying “hidden friends” – WG21/P1601R0 (2019)
🔗
- One Definition Rule – multiple definition of
inlinefunctions – Stack Overflow - Does it make any sense to use
inlinekeyword with templates? – Stack Overflow
⚓
inlinespecifier – C++ reference
🔗
- What is external linkage and internal linkage? – Stack Overflow
- P.Goldsborough. Internal and external linkage in C++ (2016)
⚓
- Storage class specifiers – C++ reference
🔗
- Exceptions – C++ reference
- H.Sutter. When and how to use exceptions – Dr.Dobb’s Journal (2004)
- When should I really use
noexcept? – Stack Overflow
🔗
- What are the basic rules and idioms for operator overloading? – Stack Overflow
⚓
operatoroverloading – C++ reference- Canonical implementations – C++ reference
🔗
- Undefined behavior and sequence points – Stack Overflow
⚓
- Order of evaluation – C++ reference
🎥
- A.O’Dwyer.
dynamic_castfrom scratch – CppCon (2017)
⚓
dynamic_castconversion – C++ reference
📝
- Since C++20, some of type punning can be done using
std::bit_cast, seestd::bit_cast– The standard library and Boost.
🔗
- Type punning – Wikipedia
- 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)
- What is the strict aliasing rule? – 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)
⚓
- Options that control optimization: Type punning – GCC documentation
🔗
- 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) - Why doesn’t ADL find function templates? – Stack Overflow
:movie:
- 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/P0846R0 (2017)
🔗
- Move-only version of
std::function– Stack Overflow - How to create an
std::functionfrom a move-capturing lambda expression? – Stack Overflow
⚓
std::function– C++ reference
🔗
- R.Chen. Non-capturing C++ lambdas can be converted to a pointer to function, but what about the calling convention? (2015)
- A.Allain. Lambda functions in C++11 – the definitive guide (2011)
- 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
🎥
- A.O’Dwyer. Back to basics: Lambdas from scratch – CppCon (2019)
⚓
- L.Dionne, H.Tong. Wording for lambdas in unevaluated contexts – WG21/P0315R4 (2017)
🎥
⚓
- C++17 compiler support – C++ reference
🎥
- A.Meredith. How C++20 can simplify
std::tuple– ACCU (2019)
⚓
- C++2a compiler support – C++ reference
🔗
- Structured bindings and tuple of references – Stack Overflow
🔗
- 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/privatestatus of data members? – Stack Overflow
🎥
- M.Kruse.
v.~uint32_t();– CppCon (2019)
🔗
- Accessing private members – Stack Overflow
- J.Schaub. Access to private members. That’s easy! (2010))
🔗
- 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/P1040R0 (2018)
🔗
- Trivial, standard-layout, POD, and literal types – Visual C++ language reference (2018)
- What are aggregates and PODs and how/why are they special? – Stack Overflow
- Trivial vs. standard layout vs. POD – Stack Overflow
See also Floating-point arithmetic – Numeric data structures and algorithms.
🔗
- D.Howard. Byte swapping floating point types (2007)
🔗
long double(GCC specific) and__float128– Stack Overflow- How to use GCC 4.6.0 libquadmath and
__float128on x86 and x86_64 – Stack Overflow
⚓
- Additional floating types – GCC documentation
⚓
- A.Meredith. Abominable function types – WG21/P0172R0 (2015)
🔗
- W.Dietz et al. Understanding integer overflow in C/C++ – Proc. ICSE (2012)
- Rule 04. Integers – SEI CERT C coding standard
- 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
🎥
- J.Bastien. Signed integers are two’s complement – CppCon (2018)
⚓
- J.Bastien. Signed integers are two’s complement – WG21/P0907R1 (2018)
An opaque type is a new type that is distinct from and distinguishable from its underlying type, yet retaining layout compatibility with its underlying type. The intent is to allow programmer control (1) over substitutability between an opaque alias and its underlying type, and (2) over overloading based on any parameter whose type is or involves an opaque alias.
📝
-
Nobody seemed to know, so I wrote a mail to the author, Walter E. Brown, and asked him. He told me that Bjarne doesn’t like that feature (anymore), so it is very unlikely that it will come anytime soon. Apparently C++ won’t get strong typedefs as core language feature. [J.Müller]
- See Opaque typedefs – Patterns and idioms for implementations at the library level.
⚓
- W.E.Brown. Toward opaque typedefs for C++1Y, v2 – WG21/N3741 (2013)
🔗
- Is null reference possible? – Stack Overflow
🔗
- Does a
constreference class member prolong the life of a temporary? – Stack Overflow
⚓
- Lifetime of a temporary – C++ reference
🔗
- H.E.Hinnant et al. A brief introduction to rvalue references (2008)
- T.Becker. C++ rvalue references explained (2013)
- Rvalue reference declarator:
&&– Microsoft Visual C++ (2016) - S.Meyers. Universal references in C++11 – Overload 111, 8 (2012)
- What is move semantics? – Stack Overflow
- Rvalues, lvalues and formal definitions – Stack Overflow
- Pass by value vs pass by rvalue reference – Stack Overflow
- Advantages of using
forward– Stack Overflow
🎥
- N.Josuttis. The nightmare of move semantics for trivial classes – CppCon (2017)