~/talk

Class Template Argument Deduction in C++17

Talkat ACCU 2018 · 2018-04-11..04-14· [c-and-cpp]
links:none on file
slides:none on file

Explains how C++17 class template argument deduction actually works in two phases, shows real STL examples (pair, vector, array, set, map, tuple, std::function) and exposes concrete pitfalls: list-initialization wins, deduction uses the primary template, aggregates require explicit deduction guides, and CTAD can silently produce unsafe code for smart pointers. Demonstrates fixes: type_identity idiom, member typedefs or extra constructor template parameters, order-dependent guides, and when to prefer make_shared/make_unique for safety.

AI-written summary · about

  1. 0:00Intro
  2. 1:51template argument deduction in C++98
  3. 12:27vector
  4. 12:53pitfall!
  5. 13:49magic!
  6. 17:00trap #1: the order matters
  7. 19:14trap #2: list-initialisation has priority
  8. 19:51sequence containers
  9. 21:20map
  10. 23:31locks & mutexes
  11. 24:15example with no arguments
  12. 24:32other STL classes...
  13. 26:36smart pointers
  14. 29:34how to disable CTAD
  15. 30:10type identity idiom
  16. 32:06member typedef
  17. 32:48templated ctor
  18. 34:00std: function
  19. 35:49deduction guides SFINAE
  20. 44:02aggregates need explicit guides
  21. 46:36CTAD uses the primary template
  22. 51:00CTAD not just in declarations!
  23. 52:07no CTAD in nested types
  24. 53:12CTAD + smart pointer conversions
~/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.