|
Dedekind 0.0.0
A structuralist C++23 Module Library
|
Pure syntactic shape: T closes strictly under +, -, * (binary and unary -). Textbook closure — results are exactly T, not just convertible to T.
More...
Pure syntactic shape: T closes strictly under +, -, * (binary and unary -). Textbook closure — results are exactly T, not just convertible to T.
Use this concept where the callsite needs the standard operators {+, -, *} to compile and to close strictly on T. This is the textbook ring-closure reading: if T's + returns something other than T (e.g. via integer promotion, as in bool + bool -> int), then T is genuinely not closed under +, and the concept correctly refuses.
Carriers that fail strict closure under standard operators (bool, char, narrow signed types) often still carry ring structure under functor-wrapped operators — std::bit_xor<bool>{}(a,b) returns bool by the functor's signature regardless of the internal integer-promotion path. For those carriers the shape companion is the universal-algebra anchor IsAlgebra<T, Add, Mult> from :universal, which checks the functors close on T rather than the literal operators. The two shape concepts are siblings; pick whichever matches the callsite's actual operator surface.
Pattern-(b) carriers (e.g. Rational<long> under the active numeric policy, IEEE double) satisfy this shape concept while the strict category::IsRing refuses — the literal-shape is the right concept to gate templated bodies whose strict half cannot fire. The strict categorical counterpart is dedekind::category::IsRing<T, Add, Mult> in category:total.
Built as HasGroupOperatorsAdd and category::IsClosedUnder for *, so the shape subsumes each per-operator closure.