Back to Basics: Templates (part 2 of 2)
summary
Walks through concrete template recipes: a variadic min function that unpacks a parameter pack and uses recursion guarded by constexpr if, then replaces that recursion with uses fold expressions and a comma-separated lambda to print arbitrary args; a build_csv_line that normalizes mixed string/value types into std::string at compile time; a mac-address equality implemented with std::make_index_sequence to compare array elements; SFINAE vs tag-dispatch vs Concepts shown with working examples; demonstrates that C++20 templated lambdas shrink a 27-line solution to shows 27→13 lines with C++20 and keeps behavior identical.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 3:45Variatic Templates
- 11:00Normalized Templates
- 18:15Fault Expressions
- 25:33Templates vs overloads
- 27:52Fall expressions
- 31:38Comparing data structures
- 34:50Comparing in 27 lines
- 40:55lambdas
- 42:02variable templates
- 43:37variable template
- 45:11substitution failure
- 47:37fini
- 51:45tact dispatch
- 53:44cbsline
- 57:26requires
- 59:11template parameters
related talks
01h 27mC++20 Templates - the Next Level: Concepts and More
57mIntroduction to C++ Template Metaprogramming
58m“Template Normal Programming (part 1 of 2)”
55mTemplates Made Easy With C++20
01h 35mC++20 – My Favourite Code Examples
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 01m“Template Normal Programming (part 2 of 2)"
