std::compar...er_fallback(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::compare_strong_order_fallback β€” C++ Standard Libary page, but make it cute πŸ’–

okay so this page is from the C++ Standard Libary manual β€” yes, that’s literally how the manual name is spelled in the header, no cap. The header title is std::compar...er_fallback(3), but the actual main character is std::compare_strong_order_fallback. It’s giving β€œfallback comparison but make it a strong ordering” energy. πŸ’…βœ¨

✨ NAME ✨

std::compare_strong_order_fallback β€” std::compare_strong_order_fallback

Like… that’s the whole NAME section, bestie. We’re not gonna pretend it says more. 🫢

🌸 Synopsis 🌸

Defined in header <compare> πŸ’–

inline namespace /* unspecified */ {

    inline constexpr /* unspecified */
(since C++20)
        compare_strong_order_fallback = /* unspecified */;

}

Call signature πŸŽ€

template< class T, class U >
    requires /* see below */
constexpr std::strong_ordering
(since C++20)
    compare_strong_order_fallback( T&& t, U&& u ) noexcept(/* see below */);

Performs a three-way comparison on the subexpressions t and u, and produces a result of type std::strong_ordering, even if the operator <=> is unavailable. Iconic fallback behavior, honestly. 🌈

If std::decay_t<T> and std::decay_t<U> are the same type, std::compare_strong_order_fallback(t, u) is expression-equivalent to: πŸ’œ

  • std::strong_order(t, u), if it is a well-formed expression;
  • otherwise, t == u ? std::strong_ordering::equal : t < u ? std::strong_ordering::less : std::strong_ordering::greater

if the expressions t == u and t < u are both well-formed and each of decltype(t == u) and decltype(t < u) models boolean-testable, except that t and u are evaluated only once. Not me checking that twice β€” it literally says only once. 😭

In all other cases, std::compare_strong_order_fallback(t, u) is ill-formed, which can result in substitution failure when it appears in the immediate context of a template instantiation. That’s not being dramatic, that’s just the rules. πŸ’€

πŸŽ€ Example πŸŽ€

This section is incomplete.

Reason: no example 🫢

So no example bestie β€” it’s giving placeholder energy. πŸ¦‹

πŸ¦‹ Defect reports πŸ¦‹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. 🌸

  • DR: LWG 2114 (P2167R3) β€” Applied to: C++20 β€” Behavior as published: the fallback mechanism only required return types to be convertible to bool β€” Correct behavior: constraints strengthened

History said β€œlet’s retcon this,” and honestly they ate. πŸ’…

🌈 See also 🌈

  • strong_order (C++20) β€” performs 3-way comparison and produces a result of type std::strong_ordering (customization point object)

Obsessed with this customization point object vibe, ngl. πŸ‘‘

πŸ‘‘ Category πŸ‘‘

  • Todo no example

xoxo, your C++ Standard Libary group-chat bestie πŸ’– source/version: http://cppreference.com Β· dated 2024.06.10 Β· page: std::compar...er_fallback(3). periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from