std::weak_order (3) - Linux Manuals

std::weak_order: std::weak_order

NAME

std::weak_order - std::weak_order

Synopsis


Defined in header <compare>
template< class T > (since C++20)
constexpr std::weak_ordering weak_order(const T& a, const T& b);


Compares two values using 3-way comparison and produces a result of type std::weak_ordering
Specifically,


* If the expression a <=> b is well-formed and its result is convertible to std::weak_ordering, returns that result.
* Otherwise, if the expression a <=> b is well-formed, but its result is not convertible to std::weak_ordering, then the function is defined as deleted.
* Otherwise, if the expression a <=> b is ill-formed, but the expressions a == b and a < b are both well-formed and convertible to bool,


      * if a == b is true, returns std::weak_ordering::equivalent
      * otherwise, if a < b is true, returns std::weak_ordering::less
      * otherwise, returns std::weak_ordering::greater


* Otherwise, the function is defined as deleted.

Parameters


a, b - values to compare

Return value


A value of type std::weak_ordering, as described above.

Notes

Example


 This section is incomplete
 Reason: no example

See also


weak_ordering the result type of 3-way comparison that supports all 6 operators and is not substitutable
              (class)
(C++20)


strong_order performs 3-way comparison and produces a result of type std::strong_ordering
              (function template)
(C++20)


partial_order performs 3-way comparison and produces a result of type std::partial_ordering
              (function template)
(C++20)


weak_equal performs 3-way comparison and produces a result of type std::weak_equality
              (function template)
(C++20)