std::totall...rdered_with(3)
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 β:
- The concept
std::totally_orderedspecifies 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 π - The concept
std::totally_ordered_withspecifies that the comparison operators==,!=,<,>,<=,>=on (possibly mixed)TandUoperands 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 π - The exposition-only concept
__PartiallyOrderedWithspecifies that a value of typeTand a value of typeUcan 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 thatoperator <=>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
- 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