~/talk

Class template argument deduction in C++17

Talkat CppCon 2018 · 2018-09-23..09-28· [c-and-cpp]
links:none on file
slides:none on file

Class template argument deduction (CTAD) in C++17 is explained as a two-step deduction process: synthesize function-like deduction candidates from constructors, deduce template arguments, then instantiate the class. Practical details include writing deduction guides for iterator-to-container cases, SFINAE-friendly guides, and techniques to disable CTAD (the type_identity idiom, templated constructors, or typedef indirection). Important pitfalls: brace vs parenthesis chooses initializer_list or range constructors, copy-vs-list ambiguity with one vs multiple args, smart pointers deliberately disable CTAD for safety, and aggregates/aliases remain problematic for future C++20 fixes.

AI-written summary · about

  1. 0:00Introduction
  2. 1:41Class template argument deduction
  3. 5:16How does it work
  4. 11:12Make functions
  5. 12:47Vector
  6. 17:59Recommendation
  7. 19:09Priority
  8. 20:41Set
  9. 21:50Map
  10. 26:25No constructor arguments
  11. 28:09Why you should be careful
  12. 29:23Smart pointers
  13. 30:51Race
  14. 31:52Seated
  15. 32:38Disable C10
  16. 33:44Type identity idiom
  17. 35:45Other techniques
  18. 37:41STL deduction guides
  19. 38:45Vector deduction guides
  20. 42:13Vector deduction guide
  21. 43:27Array deduction guide
  22. 47:15Primary template only
  23. 49:33Should you do this
  24. 51:07Smart pointer constructors
  25. 51:37Signatures
  26. 52:16Unique pointers
  27. 53:04String views
  28. 54:00Dont use deduction guides
  29. 55:29CTF proposals
  30. 56:19Aggregates
  31. 57:10Aggregate Guide
  32. 58:26Type Aliases
  33. 59:17Template Arguments
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.