Peeking Safely at a Table with Concepts
summary
Claim: use C++20 Concepts and constexpr predicates to verify at compile time that read‑only action tables have contiguous keys so indexing needs no runtime invariant checks. Implementation: a concept named retractable_by_key, a constexpr checker plus a constrained function play_entry that converts an action to an index and returns the actor in O(1). Result: the compiler proves table structure, eliminates bounds checks, preserves near‑optimal speed and memory safety, and the technique composes across many table types via generic constraints.
AI-written summary · about
chapters (6)
- 0:00Start
- 6:35WHAT ARE CONCEPTS?
- 8:51HOW DO I USE A CONCEPT?
- 12:17A COMPILE-TIME PREDICATE: RETRACTIBLE SPACE
- 15:31WITH CONCEPTS, GENERICALLY
- 19:14WITH CONCEPTS, SAFELY: CAPTURE STRUCTURAL COMPUTATION
related talks
58mConcept Based Testing
06mConstraints not Satisfied
01h 02mDiscovering a User-Facing Concept
01h 11mConcepts in 60: Everything you need to know and nothing you don't
56mCute C++ Tricks (and what you can learn from them): Part 2 of N
01h 28mC++ Concepts "Lite" in Practice
04mConcepts in 5
01h 36mBuilding C++ Interfaces That Are Hard to Use Incorrectly
