Advanced Template Programming in C++
Course objectives
After completing this course you will be able to:
- use generic programming techniques in C++
- use templates to write code that is fast, secure and reusable
- implement classic generic programming techniques: tag dispatching, SFINAE, CRTP
- use templates when designing classes: Policy Based Design
- implement modern templates using constraints and concepts
Course syllabus
Templates
- Function templates
- Class templates
- Template arguments
- Template argument deduction
- Explicit and partial specialization
- Compilation model
- Template aliases
- Variable templates
- Generic lambdas C++14
Variadic templates
- Variadic template functions
- Variadic template classes
- Applying Head-Tail idiom for variadic templates
- Variadic template types
std::tuple
std::variant
- Fold expressions
Generic programming techniques
- Templates and perfect forwarding
- Metafunctions and type traits
- Tag dispatching
- SFINAE &
enable_if<T>
- Traits and Policies
- Policy based design
- CRTP idiom
- Index sequences
- Type erasure - concept based polymorphism
Templates in C++20
- Concepts
- NTTP – non-type template parameters
- Templated lambdas in C++2
Prerequisites
Attendance of our Programming in C++ course or equivalent experience with C++