~/talk

Introduction to C++ Template Metaprogramming

Talkat NDC Oslo 2016 · 2016-06-08..06-10· [c-and-cpp, compilers-and-language-design]
slides:none on file

Covers concrete techniques for real code: uses C++11/14 features like type_traits, void_t trick for member detection, and SFINAE via enable_if to disable overloads; shows three selection strategies—explicit specialization, tag dispatch, and enable_if—to pick faster algorithm variants (example: memcpy-style fast copy and O(1) vs O(n) distance). Replaces recursive metafunctions with constexpr functions and builds a compile-time cstr plus a static_assert-based constexpr string validation for printf-like format checks. Notes GCC/Clang work; older MSVC has limits.

AI-written summary · about

  1. 0:00Intro
  2. 1:42Motivation: Checking Type Constraints
  3. 3:59Motivation: Algorithm Selection
  4. 5:18Motivation: Compile-Time Computation Some fairly complex computations can be performed ahead-of-time
  5. 5:57Reminder: Class Template Specialization
  6. 7:03A large collection of metafunctions that check properties of types
  7. 9:01Type Traits and static assert
  8. 10:19Non-Constraining Use of Traits
  9. 17:41Member Detection with void_t
  10. 23:24Generalized Version (Expression SFINAE)
  11. 27:37Specializing a Template Based on Traits - There are multiple approaches, each with its merits Hand-written template specialisation
  12. 28:22Hand-Written Template Specialization
  13. 31:56Tag Dispatch Overload functions on a type that depends on a type tra les
  14. 34:11distance_helper
  15. 35:24std::enable_if
  16. 43:39Recursive Templates
  17. 46:29Some Simple Uses
  18. 47:29constexpr Over Types
  19. 51:52Compile-Time Safe printf
~/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.