Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::category::HasTotalProduct Concept Referenceexport

Whether T's product is defined on all of T: a word narrower than int multiplies after promotion to int, and the largest product must fit it. unsigned char's does (255 · 255); unsigned short's does not (65535 · 65535 overflows int, undefined as -INT_MIN is), so it is refused as int is. Decided by the compiler: undefined behaviour is no constant expression. Unsigned words only: there the product grows with its factors, so the largest is the one that may overflow, and numeric_limits names it (a type without limits has max() == T{}, and the probe would check only 0 · 0). More...

Concept definition

template<typename T>
concept dedekind::category::HasTotalProduct = std::unsigned_integral<T> && requires {
typename std::bool_constant<(static_cast<void>(std::numeric_limits<T>::max() *
std::numeric_limits<T>::max()),
true)>;
}
Whether T's product is defined on all of T: a word narrower than int multiplies after promotion to in...
Definition species.cppm:492

Detailed Description

Whether T's product is defined on all of T: a word narrower than int multiplies after promotion to int, and the largest product must fit it. unsigned char's does (255 · 255); unsigned short's does not (65535 · 65535 overflows int, undefined as -INT_MIN is), so it is refused as int is. Decided by the compiler: undefined behaviour is no constant expression. Unsigned words only: there the product grows with its factors, so the largest is the one that may overflow, and numeric_limits names it (a type without limits has max() == T{}, and the probe would check only 0 · 0).

Template Parameters
Tthe carrier, an unsigned word.