Back to Basics: Templates (part 1 of 2)
summary
Part 1 explains concrete mechanics: templates are recipes that the compiler parses in phase 7 parses templates and generates in phase 8 instantiates them. Examples show where templates beat old C patterns (qsort comparator casts that silently fail) and when to use explicit instantiation to cut compile time or export instantiations from a DLL. Covers function/class/alias/variable templates, non-type and template-template parameters, explicit specialization for char const* comparisons, and ODR rules.
AI-written summary · about
chapters (43)
- 0:00Start
- 2:31Features of Templates
- 2:43References
- 4:02What Are Templates and Why Do We Have Them in the Language
- 4:23Function Overloading
- 5:08A Singly Linked List
- 6:01Type Erasure
- 6:15Qsort
- 8:30Reusing Code That Used Macros
- 10:01Generic Programming
- 11:02Lift Algorithms and Data Structures from Concrete Examples to Their Most General and Abstract Form
- 12:03Template Categories
- 13:18Class Templates
- 14:31Example of a Member Function Template
- 15:38Alias Templates
- 17:23General Row Vector
- 17:58Variable Templates
- 20:44Initialized Fill
- 21:27Lambda Templates
- 26:23Translation Units
- 27:22Translation Unit
- 27:49Syntax Analysis
- 28:31Sample Translation Unit
- 29:31Declarations and Definitions
- 32:46Template Declarations and Definitions
- 33:44Member Function Declaration
- 36:55Template Parameters and Template Arguments
- 38:37Type Template Parameters
- 39:12Template Template Parameters
- 44:02Template Ids
- 44:29From Template to Specialization
- 47:04The Relationships between Instantiation and Specialization
- 47:49Instantiation
- 48:39Implicit on-Demand or Automatic Instantiation
- 50:59Implicit Instantiation
- 51:24Explicit Instantiation
- 51:48Explicit Instantiation Request
- 52:49Instantiate Individual Member Functions
- 55:04Explicit Instantiations
- 55:22Some Real World Uses for Explicit Instantiation
- 56:24Shared Libraries or Dlls
- 57:02Explicit Specialization
- 59:57Relationships between Instantiation and Specialization
related talks
01h 03mBack to Basics: Declarations in C++
01h 03mTemplates Made Easy with C++20
07mLightning Talk: Higher-Order Template Metaprogramming with C++23
01h 01mBack to Basics: Concepts in C++
01h 03mTemplate-less Metaprogramming in C++
59mCute C++ Tricks, Part 2.5 of N - Code You Should Learn From & Never Write
01h 04mBack to Basics: Object-Oriented Programming in C++
06mLightning Talk: C++20 - A New Way of Meta-Programming?
