“Concepts and Contracts: When, What, and How”
summary
Goal: implement a library function template that accepts exactly one positive integral parameter and rejects zero, negatives, chars, bools, non-integers, and extra args. Multiple implementations are shown: explicit specializations (fragile), std::type_traits checks, a wrapper integral<T> helper, and a clean concepts-based signature combined with an expects contract for runtime preconditions. Examples compile and run from the GitHub repo; tool reality: GCC -fconcepts and experimental Clang forks exist, contracts support is sparse, front-ends disagree, and contracts expose axiom-for-static-tools and problematic constexpr/runtime interactions.
AI-written summary · about
chapters (16)
- 0:00Introduction and setup
- 1:59What are concepts and contracts
- 2:21Concepts implementation status
- 3:24Concepts example with outable
- 6:36Contracts overview and example
- 9:06Contracts implementation status
- 14:07Solving the challenge with traits
- 21:04Concepts features and requires clauses
- 23:37Contracts with attributes
- 26:50Concepts with named constraints
- 29:44Combining concepts and contracts
- 35:08Applying to standard library
- 45:40Uncheckable contracts and axioms
- 52:10Compile-time contract checking
- 58:48Future integration of features
- 1:00:14Summary and Q&A
related talks
54mC++ Concepts for Developers
01h 28mC++ Concepts "Lite" in Practice
01h 27mC++20 Templates - the Next Level: Concepts and More
01h 21mProgramming with Contracts in C++20
59mMetaprogramming: From Templates to Concepts
01h 34mContracts programming after C++17
01h 00mConcepts in C++20: Revolution or Evolution
52mConcepts: The Future of Generic Programming
