std::strong_order(3)
β¨ std::strong_order(3) β¨
okay so bestie, you're on the std::strong_order(3) page from the C++ Standard Libary manual β yes, that's the manual name right there, spelling and all π
β and we're about to make this 3-way comparison thing make sense. No cap. π«Ά
π NAME π
std::strong_order β std::strong_order
Literally the name. Iconic of it. π
πΈ Synopsis πΈ
Defined in header <compare>:
Defined in header <compare>
inline namespace /* unspecified */ {
inline constexpr /* unspecified */ strong_order = /* unspecified
(since C++20)
*/;
}
Call signature
template< class T, class U >
requires /* see below */
constexpr std::strong_ordering strong_order( T&& t, U&& u )
noexcept(/* see below */);
This thing compares two values using 3-way comparison and produces a result of type std::strong_ordering. Periodt. π
Let t and u be expressions, and let T and U denote decltype((t)) and decltype((u)) respectively. Then std::strong_order(t, u) is expression-equivalent to:
- If
std::is_same_v<std::decay_t<T>, std::decay_t<U>>istrue:std::strong_ordering(strong_order(t, u)), if it is a well-formed expression with overload resolution performed in a context that does not include a declaration ofstd::strong_order,- otherwise, if
Tis a floating-point type:- if
std::numeric_limits<T>::is_iec559istrue, performs the ISO/IEC/IEEE 60559totalOrdercomparison of floating-point values and returns that result as a value of typestd::strong_ordering(note: this comparison can distinguish between the positive and negative zero and between the NaNs with different representations), - otherwise, yields a value of type
std::strong_orderingthat is consistent with the ordering observed byT's comparison operators,
- if
- otherwise,
std::strong_ordering(std::compare_three_way()(t, u))if it is well-formed.
- In all other cases, the expression is ill-formed, which can result in substitution failure when it appears in the immediate context of a template instantiation.
tiny warning bestie: that last bullet is the βnot valid hereβ case β it's ill-formed, and it can cause substitution failure in a template instantiation's immediate context. Not me being dramatic, that's just what the page says. π
π Example π
This section is incomplete.
Reason: no example.
we love a mysterious incomplete section, honestly. π
π See also π
strong_ordering(C++20)β the result type of 3-way comparison that supports all 6 operators and is substitutable (class)weak_order(C++20)β performs 3-way comparison and produces a result of typestd::weak_ordering(customization point object)partial_order(C++20)β performs 3-way comparison and produces a result of typestd::partial_ordering(customization point object)compare_strong_order_fallback(C++20)β performs 3-way comparison and produces a result of typestd::strong_ordering, even ifoperator<=>is unavailable (customization point object)
ποΈ Category ποΈ
Todo no example
and that's the whole page, bestie! Source: http://cppreference.com, date/version: 2024.06.10, page: std::strong_order(3). Mwah ππ¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms