Templates & Generic Programming
Write genuinely generic, reusable, zero-overhead abstractions using templates, concepts, and compile-time programming.
Template Fundamentals
Function Templates & Type Deduction
Learn how to write functions that work with any type. Understand template argument deduction, non-type parameters, and why templates live in headers.
Class Templates & CTAD
Build generic data structures with class templates. Understand member definitions, default arguments, and how C++17's CTAD lets you omit template arguments.
Advanced Templates
Template Specialization & Tag Dispatch
Master full and partial specialization, learn when to prefer overloading, and discover tag dispatch and if constexpr as alternatives for compile-time branching.
Variadic Templates & Fold Expressions
Handle any number of template arguments with parameter packs. Master fold expressions for elegant, recursive-free pack processing.
SFINAE, Type Traits & enable_if
Understand the Substitution Failure Is Not An Error principle, use type traits for compile-time introspection, and constrain templates with enable_if.
Modern Generic Programming
C++20 Concepts & Constraints
Define precise requirements on template arguments using concepts. Write cleaner generic code with requires clauses, abbreviated function templates, and standard library concepts.
constexpr, consteval & Compile-Time Programming
Move computation from runtime to compile time using constexpr, consteval, and constinit. Build lookup tables, validate configurations, and use constexpr containers.
Template Metaprogramming Patterns
Master advanced template patterns: CRTP for static polymorphism, policy-based design for flexible composition, type erasure for runtime generics, and guidelines for when to use templates vs virtual dispatch.