Back to Basics: Templates (part 1 of 2)
summary
Covers concrete template patterns: function, class and method templates; shows a constexpr size(T (&)[N]) that preserves array size with std::array example preserving size and demonstrates specialization for double to compare floats. Uses C++ Insights to show instantiations and alias templates like char_array = std::array<char,N>. Argues that replacing size parameters with std::span to avoid code bloat prevents many instantiations, and shows type_traits plus constexpr if and concepts to select compile-time paths and produce clearer errors.
AI-written summary · about
chapters (24)
- 0:00Introduction
- 0:25Welcome and conference
- 1:12Speaker background
- 2:16Generic programming
- 4:56Template fundamentals
- 7:34Types of templates
- 8:46Template parameters
- 10:39Function template example
- 13:27Min function template
- 15:04Compiler insights
- 17:36Template specialization
- 20:55Class templates
- 25:40Template instantiation
- 31:34Class template deduction
- 36:42Method templates
- 41:01Template inheritance
- 46:09Alias templates
- 48:47Efficient template usage
- 52:13C++20 span
- 55:52Template guidelines
- 58:44Type traits
- 1:00:15Concepts in C++20
- 1:00:45Compile-time evaluation
- 1:04:24Closing remarks
related talks
57mIntroduction to C++ Template Metaprogramming
58m“Template Normal Programming (part 1 of 2)”
54mGeneric Programming Without (Writing Your Own) Templates
01h 37mRethinking the Way We Do Templates in C++ even more
01h 01m“Template Normal Programming (part 2 of 2)"
01h 30mRethinking the Way We Do Templates in C++
53mC++ Variadic Templates and Parameter Packs
01h 27mC++20 Templates - the Next Level: Concepts and More
