Generic Programming Without (Writing Your Own) Templates
summary
Shows concrete replacements for hand-rolled templates using C++17/C++20: use std::span (or GSL span) to accept any contiguous range and avoid template bloat but beware const placement and dangling lifetimes; return heterogeneous results with std::variant (example: quadratic solver returning monostate / double / pair<double,double>) and handle cases with visit/overload; use std::any for truly dynamic values but expect heap allocations and runtime type checks; std::function trades compile-time templates for runtime type-erasure and possible allocations.
AI-written summary · about
chapters (10)
- 0:00Intro
- 1:04Templates
- 6:23How to use a span
- 8:54Pitfalls
- 20:24a type-safe union?
- 23:08Example
- 30:07overload pattern
- 35:39void
- 40:36Use cases
- 49:03function_ref
related talks
57mIntroduction to C++ Template Metaprogramming
01h 35mC++20 – My Favourite Code Examples
01h 30mTaming C++23 - The Things About C++23 You Do Not Know
01h 02mC++20 - My Favourite Code Examples
01h 01m“Template Normal Programming (part 2 of 2)"
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
53mC++ Variadic Templates and Parameter Packs
