C++20 Templates - the next level
summary
Claims that C++20 makes templates readable and testable with concrete features backed by Compiler Explorer and compile-time checks. Concepts and the requires expression let code state and reuse four concrete checks (same-type, operator+, noexcept, return-type) instead of obscure enable_if hacks. Non-type template parameters accept doubles and class-like fixed_string values. Lambdas gain a template head so a templated lambda can enforce identical parameter types. Tests use static_assert on concepts to fail at compile time.
AI-written summary · about
chapters (18)
- 0:00Start
- 2:09Concepts
- 11:37The Requires Clause
- 13:57Constraint Placeholder Types
- 15:17Trailing Required Clause
- 17:58Return Type
- 18:38Requires Expression
- 21:20Simple Requirement
- 21:33Sample Requirement
- 22:49Nested Requirement
- 24:26The Compound Requirement
- 27:16Ad Hoc Constraint
- 32:22Abbreviated Function Templates
- 38:09Inheritance
- 41:11Error Messages
- 48:38Fixed String Container
- 55:25Concept Cheat Sheet
- 1:00:22Static Assert
related talks
53mFrom C++ Templates to C++ Concepts - Metaprogramming: an Amazing Journey
01h 02mBack to Basics: Templates in C++
59mC++20: the small things
01h 07mVariadic and Variable Templates in C++14
59mCombining C++17 Features
54mModern Template Techniques
01h 38mC++20: Reaching for the Aims of C++
59mBack to Basics: Generic Programming in C++
