auto Type Deduction
auto lets the compiler deduce variable types from initializers, reducing verbosity and improving maintainability.
auto lets the compiler deduce variable types from initializers, reducing verbosity and improving maintainability.
Class templates create generic classes that work with different types. Think std::unique_ptr - same class, different types.
CRTP is a template pattern where a class Derived inherits from a template base class Base, passing itself as a template argument. This enables compile-time polymorphism without virtual functions.
C++ supports two forms of polymorphism: dynamic (runtime, using virtual functions) and static (compile-time, using templates). Each has different trade-offs.
Fold expressions provide a concise way to apply operators to variadic template parameter packs. They eliminate the need for recursive template patterns.
Full specialization provides a completely custom implementation for specific template arguments. It's like saying "for this exact type, use this completely different code."
Function templates let you write one function that works with different types. The compiler generates specific versions for each type you use.
Partial specialization lets you specialize templates for a pattern of types, not just one specific type. It's like "for all pointer types" or "for all pairs of same types."
Policy-based design decomposes complex behaviors into independent policy classes combined through templates. Each policy defines one aspect of behavior, and policies are mixed together to create flexible, reusable components.
When template type deduction creates "reference to reference", C++ applies collapsing rules. This enables perfect forwarding.
SFINAE (Substitution Failure Is Not An Error) is a fundamental C++ template mechanism that enables conditional template compilation. std::enable_if is the primary tool for applying SFINAE in practice.
Template argument deduction lets the compiler figure out template parameters from function arguments automatically. No need to write func(5) when func(5) works!
Type erasure hides the concrete type behind a common interface, allowing different types to be treated uniformly without inheritance. Combines the flexibility of runtime polymorphism with the performance benefits of templates.
Type traits are compile-time tools that query and transform types. They power template metaprogramming and SFINAE, letting you write code that adapts to different types automatically.
Variadic templates accept any number of arguments of any types. They're the foundation for functions like std::make_tuple, printf, and perfect forwarding.