The Implementation of Value Types
summary
Value types require concrete choices: use a representation that minimizes padding and caches hot fields, make copies trivially copyable when possible, and favor pass‑by‑value for very small types (roughly less than two pointers) else const reference. Implement aliasing defenses (conditional copy, read‑before‑write, field recaching). Support literal types to enable non‑type template arguments; user‑defined literals are tricky for units. Beware std::string concurrency/ABI surprises that once invalidated binaries; prefer small string optimization and ensure strict weak ordering, NRVO and strong exception safety.
AI-written summary · about
chapters (39)
- 0:00Intro
- 0:33Definition of Value Types
- 1:46Attributes of Built-in Arithmetic Types
- 2:00Ad-Hoc Representation
- 3:37Mission Creep
- 4:34Operation Categories
- 5:50Mathematical
- 6:34Representational
- 6:58Semantic
- 8:15Syntactic
- 8:35String Append
- 10:09Literal Types
- 10:37Literal Values
- 12:20Redundancy
- 13:57Padding
- 16:18Trivially Copyable
- 21:59Indirect Pass by Value
- 23:12Parameter Recommendations
- 24:12Slicing
- 26:28Pass by Const Ref
- 27:35Named Return value Optimization
- 28:36Approaches
- 29:15Copy a Potentially Aliasing Parameter
- 29:55Conditionally Copy
- 30:30Conditionally Do Not Copy
- 31:45Aliasing Fields
- 32:07Read Caching Fields
- 34:36Global State
- 35:23Static Initialization Order
- 36:57Concurrency
- 39:12Exceptions
- 40:05Allocate Before Changes
- 40:36Recover Resources
- 41:32Responsibilities
- 42:11Avold Redundant Memory Access
- 43:22Inlining
- 51:04IBM System 360
- 51:34Follow Along
- 52:11Choose Portable Types
related talks
48mBack to Basics: Cpp Value Semantics
58mArgument Passing, Core Guidelines and Aliasing
01h 01mValue Semantics: Safety, Independence, Projection, & Future of Programming
51mBack to Basics: Master C++ Value Categories With Standard Tools
23mFunctional Programming in C++ (Run time vs Compile time types)
52mStrong types for strong interfaces
53mRegular Types and why do I care?
01h 00mTemplate Metaprogramming: Type Traits (part 1 of 2)
