std::compar...der_fallback(3)
okay so bestie, welcome to std::compare_partial_order_fallback, aka the std::compar...der_fallback(3) page from the C++ Standard Libary π
β¨. This is your fallback three-way comparison bestie: it performs three-way comparison on subexpressions t and u and produces a result of type std::partial_ordering, even if operator <=> is unavailable. no cap, that's the vibe.
π NAME π
std::compare_partial_order_fallback β std::compare_partial_order_fallback. like, yes, the name is the name, periodt.
π¦ SYNOPSIS π¦
Okay so here's the setup, bestie: this lives in the header <compare>, and it's giving since C++20 energy from the jump.
Defined in header <compare>
inline namespace /* unspecified */ {
inline constexpr /* unspecified */
(since C++20)
compare_partial_order_fallback = /* unspecified */;
}
Call signature
template< class T, class U >
requires /* see below */
constexpr std::partial_ordering
(since C++20)
compare_partial_order_fallback( T&& t, U&& u ) noexcept(/* see
below */);
So what does it actually do? It performs three-way comparison on subexpressions t and u and produces a result of type std::partial_ordering, even if the operator <=> is unavailable. slay.
If std::decay_t<T> and std::decay_t<U>> are the same type, std::compare_partial_order_fallback(t, u) is expression-equivalent to:
std::partial_order(t, u), if it is a well-formed expression;- otherwise,
t == u ? std::partial_ordering::equivalent :
t < u ? std::partial_ordering::less :
u < t ? std::partial_ordering::greater :
std::partial_ordering::unordered
if the expressions t == u, t < u and u < t are all well-formed and each of decltype(t == u) and decltype(t < u) models boolean-testable, except that t and u are evaluated only once.
In all other cases, std::compare_partial_order_fallback(t, u) is ill-formed, which can result in substitution failure when it appears in the immediate context of a template instantiation. π
πΈ EXAMPLE πΈ
This section is incomplete.
Reason: no example π
π DEFECT REPORTS π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. yes bestie, they went back and fixed the lore.
LWG 2114(P2167R3) β applied toC++20. Behavior as published: the fallback mechanism only required return types to be convertible tobool. Correct behavior: constraints strengthened.LWG 3465β applied toC++20. Behavior as published: the fallback mechanism did not requireu < tto be well-formed. Correct behavior: requiredu < tto be well-formed.
π SEE ALSO π
partial_order(C++20) β performs 3-way comparison and produces a result of typestd::partial_ordering(customization point object).
π CATEGORY: π
- Todo no example
mwah π β sourced from http://cppreference.com, version/date 2024.06.10, and this was the std::compar...der_fallback(3) page. bye bestie, go compare things safely π«Άβ¨
π¦ 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