What Has C++20 Ever Done For Templates?
summary
C++20 actually adds concrete template tools: concepts provide compiler-enforced predicates (std::invocable, std::same_as, predicate hierarchy) and drive overload resolution via named-concept subsumption; non-type template parameters now accept floats as NTTPs and “structural” literal-class values (and lambdas without captures), with gotchas: floating-point bit-equality matters and private members or non-constexpr destructors forbid structural NTTPs; templated and constrained lambdas let parameters share template types and use constraints directly; examples show compile-time string keys for strong types and ratio types for units, and the new features work but require attention to representation and visibility rules.
AI-written summary · about
chapters (23)
- 0:00Start
- 2:10Feedback and Questions
- 3:18More Resources
- 4:05What Has C-20 Ever Done for Templates?
- 5:29Use Case
- 7:53What Is a Concept?
- 8:41Concepts From the Standard Library
- 11:20Error Messages and Templates With Constraints
- 12:29Requires Clause
- 13:58Even More Constraints
- 17:01Pitfalls
- 22:35Type Requirements
- 23:33Compound Requirements
- 25:23Nested Requirements
- 26:00Floating PointContainer Concepts
- 29:26A Function Which Takes Another Callable
- 31:10std::function for Constraining
- 32:06Implementation With Standard Concepts
- 38:36Examples for Subsumption
- 47:13Overload Resolution With Standard Concepts
- 50:50Summary
- 53:19Examples For Structural Types
- 56:02Floats and Doubles as NTTP
related talks
01h 27mC++20 Templates - the Next Level: Concepts and More
01h 00mConcepts in C++20: Revolution or Evolution
54mC++ Concepts for Developers
01h 01mRethinking the Way We Do Templates in C++
01h 30mRethinking the Way We Do Templates in C++
54mData in the Type System: Complex Non-Type Template Parameters in C++20
52mConcepts: The Future of Generic Programming
58mExploration of C++20 Meta Programming
