# std::weak_equal

From cppreference.com
< cpp‎ | utility

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

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

Specifically,

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

  - if a == b is true, returns std::weak_equality::equivalent
  - otherwise, returns std::weak_equality::nonequivalent

- Otherwise, the function is defined as deleted.

### Parameters

a, b | - | values to compare

### Return value

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

### Notes

### Example

| This section is incomplete Reason: no example

### See also

weak_equality (C++20) | the result type of 3-way comparison that supports only equality/inequality and is not substitutable (class)
strong_equal (C++20) | performs 3-way comparison and produces a result of type std::strong_equality (function template)
strong_order (C++20) | performs 3-way comparison and produces a result of type std::strong_ordering (function template)
partial_order (C++20) | performs 3-way comparison and produces a result of type std::partial_ordering (function template)
weak_order (C++20) | performs 3-way comparison and produces a result of type std::weak_ordering (function template)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/weak_equal&oldid=105541"