std::totall...rdered_with(3)

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

okay so this is the std::totall...rdered_with(3) page from the C++ Standard Libary manual, and bestie, we are about to get into some extremely ordered concept business πŸ’…βœ¨

πŸŽ€ NAME πŸŽ€

std::totally_ordered, std::totally_ordered_with β€” the NAME line is literally std::totally_ordered,std::totally_ordered_with - std::totally_ordered,std::totally_ordered_with (yes, it says it twice, iconic), and this page is all about those two concepts. periodt.

✨ Synopsis ✨

Defined in header <concepts>. here's the code, copied exactly so nobody comes for my edges:

          Defined in header <concepts>
          template< class T >

          concept totally_ordered =                                     (1)
       (since C++20)

              std::equality_comparable<T> && __PartiallyOrderedWith<T,
          T>;
          template< class T, class U >

          concept totally_ordered_with =
              std::totally_ordered<T> &&
              std::totally_ordered<U> &&
              std::equality_comparable_with<T, U> &&                    (2)
       (since C++20)
              std::totally_ordered<
                  std::common_reference_t<
                      const std::remove_reference_t<T>&,
                      const std::remove_reference_t<U>&>> &&

              __PartiallyOrderedWith<T, U>;
          template< class T, class U >

          concept __PartiallyOrderedWith =
              requires(const std::remove_reference_t<T>& t,
                       const std::remove_reference_t<U>& u) {
                  { t <  u } -> boolean-testable;
                  { t >  u } -> boolean-testable;
                  { t <= u } -> boolean-testable;                       (3)
       (exposition only*)
                  { t >= u } -> boolean-testable;
                  { u <  t } -> boolean-testable;
                  { u >  t } -> boolean-testable;
                  { u <= t } -> boolean-testable;
                  { u >= t } -> boolean-testable;

              };

now let's decode the numbered tea β˜•:

  1. The concept std::totally_ordered specifies that the comparison operators ==, !=, <, >, <=, >= on a type yield results consistent with a strict total order on the type. yes, all six of them. it's giving "everybody in line" energy πŸ‘‘
  2. The concept std::totally_ordered_with specifies that the comparison operators ==, !=, <, >, <=, >= on (possibly mixed) T and U operands yield results consistent with a strict total order. Comparing mixed operands yields results equivalent to comparing the operands converted to their common type. mixed-operand slay πŸ’…
  3. The exposition-only concept __PartiallyOrderedWith specifies that a value of type T and a value of type U can be compared in a partial order with each other (in either order) using <, >, <=, and >=, and the results of the comparisons are consistent. it's exposition-only, which the page flags with (exposition only*).

πŸ‘€ See also πŸ‘€

  • three_way_comparable, three_way_comparable_with β€” specifies that operator <=> produces consistent result on given types (C++20) (concept).

mwah πŸ’– source: http://cppreference.com; version/date: 2024.06.10; manual: std::totall...rdered_with(3). bye bestie, go be totally ordered 🫢🌈

πŸ“¦ where this page comes from