Extending and Simplifying C++: Thoughts on Pattern Matching using `is` and `as`
summary
C++ evolution proposes general pattern matching via operator is queries and operator as casts that unify variant any optional and static type traits; the paper (P1371/P2392) argues this replaces ad‑hoc APIs and simplifies templates. A Circle compiler prototype and Godbolt demos implement structured decompositions, predicates (e.g., even constrained by concepts), and dynamic checks for any/variant/optional, uncovering a few bugs during implementation but otherwise working and showing clearer, reusable extraction and matching semantics.
AI-written summary · about
chapters (26)
- 0:00Intro
- 2:20Is C Finished
- 4:30Overview of Pattern Matching
- 8:00Why not switch
- 9:00Current proposals
- 10:20Frequently asked questions
- 11:35My proposal
- 13:25Dynamic typing
- 18:00Reinterpret cast
- 18:49C compiler
- 20:35Implicit templates
- 22:23Integral
- 23:25Pattern Matching
- 25:20IfConstExpert
- 26:11IfPer
- 26:45Even
- 29:39String literal
- 30:22Screenshot
- 31:30Operator is Operator as
- 36:23Unified function operator syntax
- 37:32Variants
- 38:30Anycast
- 39:21Static typing
- 54:30Previous Proposal
- 57:58Inspect
- 58:35Happy Marriage
related talks
01h 00mTemplate Metaprogramming: Type Traits (part 1 of 2)
59mTemplate Metaprogramming: Type Traits (part 2 of 2)
01h 05mExpressing Implementation Sameness and Similarity - Polymorphism in Modern C++
49mA Journey Into Non-Virtual Polymorphism in C++
59mstd variant and the power of pattern matching
53mProduct Types for C++2x
30mAdding Pattern Types to the Type System
53mFrom C++ Templates to C++ Concepts - Metaprogramming: an Amazing Journey
