~/talk

Back to Basics: Algebraic Data Types

Talkat CppCon 2020 · 2020-09-14..09-18· [compilers-and-language-design]
slides:none on file

C++17 algebraic data types are shown as concrete tools: std::pair and std::tuple are product types with predictable memory footprint and padding; std::variant is a sum type that stores an index (so usually a few bytes larger) and supports std::visit for type-safe pattern dispatch; std::optional is a one-bit-ish sum (T + 1) that enables deferred, heap-free lifetime via emplace. The talk warns about valueless by exception on bad emplace, recommends named structs over returning tuples, and explains get/get_if and in-place construction.

AI-written summary · about

  1. 0:00Introduction
  2. 1:15Motivation and overview
  3. 8:21Product types explained
  4. 11:07Sum types explained
  5. 16:03Where to use pair and tuple
  6. 19:35Why use optional
  7. 25:21Common vocabulary
  8. 31:21In-place construction
  9. 41:33Optional deep dive
  10. 49:58Detecting variant alternatives
  11. 56:38Pair and tuple patterns
  12. 1:04:24Named types over tuples
  13. 1:06:31Conclusion and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.