Back to Basics: Generic Programming in C++
Talkat CppCon 2024 · on Wednesday, 2024-09-18· at 09:00· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Explains concrete C++ template rules: templates belong in headers, substitution vs instantiation behaves differently, member functions of class templates are instantiated only when used, and SFINAE means substitution failure is not an error so overload sets can drop candidates. Covers type, non‑type, and template template parameters, C++20 Concepts/requires and enable_if patterns, partial/full specialization gotchas (safe_sizeof example), and practical guidelines: prefer constrained templates, make function template parameters deducible, avoid specializing function templates, and keep overloads and APIs simple.
AI-written summary · about
chapters (18)
- 0:00Generic programming intro
- 1:12What generic programming means
- 5:06C++ templates as GP
- 6:55Templates in header files
- 9:45Template parameter types
- 16:26Substitution and instantiation
- 23:17Template argument matching
- 29:39Calling function templates
- 31:03Constraining template args
- 34:15Writing class templates
- 35:59Specializing templates
- 41:41Workarounds for unspecializable
- 42:43C++ declaration syntax
- 47:21Deducing template args
- 49:30Avoiding overload sets
- 52:02Choosing function template args
- 53:28Specializing function templates
- 55:15Summary and advice
related talks
01h 02mBack to Basics: Templates in C++
01h 07mBack to Basics: Templates (part 2 of 2)
01h 01mthe Concepts of concepts
53mFrom C++ Templates to C++ Concepts - Metaprogramming: an Amazing Journey
01h 03mBack to Basics: The C++ Core Guidelines
01h 05mBack To Basics: Overload Resolution
01h 02mBack To Basics: The Special Member Functions
01h 01mBack to Basics: C++ API Design
