The Pattern Matching We Already Have
summary
Argues that C++ already has real pattern matching: concrete mechanisms are overload resolution, partial/explicit template specializations, template argument deduction and class template argument deduction (CTAD introduced in C++17). Demonstrates with concrete code: overloads resolving three different inputs to the bool overload, reference collapsing and forwarding rules that explain why T&& becomes T& for lvalues, non‑deduced contexts that break deduction, and how deduction guides map constructors to deduced class types. C++26 still omits proposed match/inspect keywords.
AI-written summary · about
chapters (6)
- 0:00Pattern matching in C++
- 3:49Function overload resolution
- 19:18Template specializations
- 32:02Template argument deduction
- 48:36Class template argument deduction
- 56:01Conclusion and key takeaways
related talks
01h 03mPattern Matching: A Sneak Peek
51mSimple, Extensible Pattern Matching in C++14
01h 04mClass Template Argument Deduction in C++17
01h 00m“MPark.Patterns: Pattern Matching in C++”
07mPattern Matching in C++14
48mClass Template Argument Deduction: A New Abstraction
01h 00m“Using Compile-time Code Generation to build an LLVM IR Pattern Matcher”
01h 07mDesign Patterns in Modern C++
