C++ Class Template Argument Deduction - History, Uses, & Enabling it for Classes
summary
C++17 CTAD explains why the language now fills class template arguments for you, how the compiler generates implicit vs explicit deduction guides, and when to write guides yourself (iterator_traits and allocator_traits examples, std::vector demos). It shows tools and practices: run compile‑fail tests, use static_assert same_type to check results, and constrain guides with Concepts or SFINAE. It reports that CTAD reduces boilerplate, that implicit guides are compiler‑generated and not editable, and that C++20 adds alias/aggregate/inherited‑ctor CTAD.
AI-written summary · about
chapters (44)
- 0:00Intro
- 0:26About Me
- 2:10What is Class Template Argument Deduction
- 4:37Class Template Argument Definition
- 4:57Default Class Template Argument
- 5:12Template Argument Deduction
- 6:47Template Argument Deduction History
- 7:19Class Template Argument Deduction
- 9:06Why are you doing this
- 9:32What does CTAD do
- 9:50CTAD fills in the template arguments
- 11:15CTAD makes make functions less necessary
- 12:40How does it work
- 13:10Deduction
- 15:16Deduction Guide Example
- 16:21How does this work
- 17:43Its hard to understand
- 18:23Definition of Vector
- 18:45Constructors to Vector
- 26:56Iterators
- 27:43Template Parameters
- 29:09Allocators
- 29:42Values
- 29:57Default Values
- 30:57Compiler Time
- 32:01Writing Deduction Guides for Classes
- 35:52Compile Fail Tests
- 36:10Add Deduction Guides
- 36:25Existential Questions
- 39:33assertSameType
- 40:00assertSameType Example
- 41:38SharedPointer Example
- 43:15Can You Edit Deduction Guides
- 45:25Shared Pointer
- 46:40Implicit Deduction Guides
- 47:11Alias Template Deduction Guides
- 48:09Aggregate Template Deduction Guides
- 48:40Inheritance of Deduction Guides
- 49:23Summary
- 50:53Misdeduction
- 52:05Unreasonable Strings
- 52:49Cons
- 53:05Ambiguity
- 54:36Questions
related talks
01h 10mType Deduction and Why You Care
01h 11mC++20 Templates: The next level: Concepts and more
01h 03mTemplates Made Easy with C++20
01h 01mBack to Basics: Templates (part 1 of 2)
01h 04mC++ Concepts
01h 02mBack to Basics: Forwarding References - How to Forward Parameters in Modern C++
01h 03mTemplate Metaprogramming: Practical Application
01h 01mBack to Basics: Concepts in C++
