Skip to content
academia.sh

Unit 01 of 02

Template Metaprogramming

Function and class templates, specialization, variadic template parameters, type traits, overload resolution and SFINAE, static polymorphism — each paired with the question of where the cost moved.

Published Updated

Lessons

  1. 01 Function and Class Templates Function templates, template argument deduction, explicit template arguments and class templates; the compiler writing a new body for every new type, and that cost moving to compile time. 14 min read
  2. 02 Template Specialization Full and partial specialization, the primary template, selection of the most specialized match, the memory layout of the bool pack, and the cost that reading from a bit leaves to run time. 12 min read
  3. 03 Variadic Templates Parameter packs, sizeof..., pack expansion, comparing recursive expansion with fold expressions, forwarding with std::forward, and how many bodies the expansion method makes the compiler write. 12 min read
  4. 04 Type Traits Standard type traits, selection at compile time with if constexpr, static_assert, writing your own type trait, and the selection leaving zero queries at run time. 12 min read
  5. 05 Overload Resolution and SFINAE Candidates and viable candidates, the contest between a template and a non-template function, candidate elimination with enable_if_t, detection with void_t, and constraints with C++20 concepts. 12 min read
  6. 06 Static Polymorphism Dispatch at compile time with CRTP, the contrast with the virtual function version, policy classes and mixins, a static interface constrained by a concept, and selection returning to run time with variant. 13 min read

Start typing to search.

↑↓ ↵ Esc navigate · open · close