Cover
Contents
Introduction
Terminology and Conventions
Reporting Bugs and Suggesting Improvements
Chapter 1 Deducing Types
Item 1: Understand template type deduction.
Case 1: ParamType is a Pointer or Reference, but not a Universal Reference
Case 2: ParamType is a Universal Reference
Case 3: ParamType is Neither a Pointer nor a Reference
Array Arguments
Function Arguments
Item 2: Understand auto type deduction.
Item 3: Understand decltype.
Item 4: Know how to view deduced types.
IDE Editors
Compiler Diagnostics
Runtime Output
Beyond typeid
Chapter 2 auto
Item 5: Prefer auto to explicit type declarations.
Item 6: Be aware of the typed initializer idiom.
Chapter 3 From C++98 to C++11 and C++14
Item 7: Distinguish () and {} when creating objects.
Item 8: Prefer nullptr to 0 and NULL.
Item 9: Prefer alias declarations to typedefs.
Item 10: Prefer scoped enums to unscoped enums.
Item 11: Prefer deleted functions to private undefined ones.
Item 12: Declare overriding functions override.
Item 13: Prefer const_iterators to iterators.
Item 14: Use constexpr whenever possible.
Item 15: Make const member functions thread-safe.
Item 16: Declare functions noexcept whenever possible.
Item 17: Consider pass by value for cheap-to-move parameters that are always copied .
Item 18: Consider emplacement instead of insertion.
Item 19: Understand special member function generation.
Chapter 4 Smart Pointers
Item 20: Use std::unique_ptr for exclusive-ownership resource management.
Item 21: Use std::shared_ptr for shared-ownership resource management.
Item 22: Use std::weak_ptr for std::shared_ptr-like pointers that can dangle.
Item 23: Prefer std::make_unique and std::make_shared to direct use of new.
Item 24: When using the Pimpl Idiom, define special member functions in the implementation file.
Chapter 5 Rvalue References, Move Semantics, and Perfect Forwarding
Item 25: Understand std::move and std::forward.
Item 26: Distinguish universal references from rvalue references.
Item 27: Use std::move on rvalue references, std::forward on universal references.
Item 28: Avoid overloading on universal references.
Item 29: Familiarize yourself with alternatives to overloading on universal references.
Abandoning overloading
Passing by const T&
Passing by value
Tag dispatch
Tag dispatch constructors
Trade-offs
Item 30: Understand reference collapsing.
Item 31: Assume that move operations are not present, not cheap, and not used.
Item 32: Familiarize yourself with perfect forwarding failure cases.
Braced initializers
0 or NULL as null pointers
Declaration-only integral static const data members
Overloaded function names and template names
Bitfields
Upshot
Chapter 6 Lambda Expressions
Item 33: Avoid default capture modes.
Item 34: Use init capture to move objects into closures.
Item 35: Use decltype on auto&& parameters to std::forward them.
Item 36: Prefer lambdas to std::bind.
Chapter 7 The Concurrency API
Item 37: Prefer task-based programming to thread-based.
Item 38: Specify std::launch::async if asynchronicity is essential.
Item 39: Make std::threads unjoinable on all paths.
Item 40: Be aware of varying thread handle destructor behavior.
Item 41: Consider void futures for one-shot event communication.
Item 42: Use std::atomic for concurrency, volatile for special memory.