~/talk

How and When To Write a C++ Template

Talkat C++ on Sea 2024 · 2024-07-02..07-05· [software-architecture]
slides:none on file

Covers concrete rules and tradeoffs: when templates save code versus when a variant or type erasure is better, concrete examples (optional, std::find, variadic sum, PI variable template), and real fixes like preferring overloads to function-template specializations. Shows testing by defaulting a template parameter so tests inject a stub type, explains explicit instantiation to cut compile time with extern template, demonstrates modern techniques like if constexpr and concepts as safer SFINAE replacements, and uses CPInsights to reveal actual instantiations.

AI-written summary · about

  1. 0:00Introduction and motivation
  2. 1:34What are templates?
  3. 5:10Types of templates
  4. 7:13Fundamentals of templates
  5. 8:58Template instantiation
  6. 11:33Variations of templates
  7. 18:03Advanced parameters and folds
  8. 22:42Type deduction overview
  9. 23:51Complex template parameters
  10. 29:52Typename and compiler errors
  11. 35:50Function template specialization
  12. 38:48Understanding SFINAE
  13. 42:13Choosing the right abstraction
  14. 47:21Lambda templates and if constexpr
  15. 49:53Testing and architecture
  16. 56:41Tooling and conclusion
~/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.