Namespaces
Variants
Views
Actions

std::partial_order

From cppreference.com
< cpp‎ | utility
Revision as of 13:14, 29 November 2017 by Cubbi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Defined in header <compare>
template< class T >
constexpr std::partial_ordering partial_order(const T& a, const T& b);
(since C++20)

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

Specifically,

  • If the expression a <=> b is well-formed and its result is convertible to std::partial_ordering, returns that result.
  • Otherwise, if the expression a <=> b is well-formed, but its result is not convertible to std::partial_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::partial_ordering::equivalent
  • otherwise, if a < b is true, returns std::partial_ordering::less
  • otherwise, returns std::partial_ordering::greater
  • Otherwise, the function is defined as deleted.

Contents

Parameters

a, b - values to compare

Return value

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

Notes

Example

See also

Template:cpp/utility/compare/dsc weak equal
the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values
(class) [edit]
performs 3-way comparison and produces a result of type std::strong_ordering
(customization point object)[edit]
performs 3-way comparison and produces a result of type std::weak_ordering
(customization point object)[edit]