C++20 and C++23 have a limitation where fold expressions in constraints are treated as opaque atomic constraints, preventing the compiler from recognizing subsumption relationships between overloads. For example, if concept C subsumes A, the compiler cannot determine that (C<T> && ...) is more constrained than (A<T> && ...) and reports an ambiguous call. C++26 fixes this via proposal P2963R3, which introduces 'fold expanded constraints' as a new constraint category. Subsumption is extended so that (P<Ts> && ...) subsumes (Q<Ts> && ...) when both expand the same pack, use the same fold operator, and P<T> subsumes Q<T> for a single type. Fold operators must match for subsumption to apply. Clang 19 already supports this feature.
Table of contents
Constraint subsumption, brieflyThe problem: fold expressions are opaque to subsumptionThe solution: fold expanded constraintsConnection to P2841ConclusionConnect deeper2.3K Impressions