01
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.