Class Template Argument Deduction: A New Abstraction
summary
Class template argument deduction (CTAD) in C++17 claims to be more than keystroke savings: it creates a new abstraction where a template-name-plus-parentheses becomes an interface for all specializations. It uses automatic deduction candidates (constructor-derived, copy, default-constructor) plus user-written deduction guide overloads; guides join overload resolution rather than replace defaults. Practical techniques include the take-by-value guide pattern, the identity_t trick to disable automatic candidates, and targeted guides (e.g., stoul-string for char arrays); these enable new, working interfaces but need careful design.
AI-written summary · about
chapters (6)
- 0:00C++17’s hidden power
- 3:44What CTAD really is
- 18:19Deduction candidates explained
- 20:50Deduction guide toolbox
- 36:39Designing with CTAD
- 47:24Conclusion and Q&A
related talks
01h 00mInference in C++: The big picture
58mThe Pattern Matching We Already Have
01h 30mRethinking the Way We Do Templates in C++
01h 03mBack to Basics: Function and Class Templates
57mIntroduction to C++ Template Metaprogramming
01h 00mC++ Function Templates: How Do They Really Work?
01h 21mWhat Has C++20 Ever Done For Templates?
01h 13mC++ Templates Revised
