std::weak_equality (3) - Linux Manuals
std::weak_equality: std::weak_equality
NAME
std::weak_equality - std::weak_equality
Synopsis
Defined in header <compare>
class weak_equality; (since C++20)
The class type std::weak_equality is the result type of a three-way_comparison that
* admits only equality and inequality comparisons (no less-than/greater-than)
* does not imply substitutability: if a is equivalent to b, f(a) may not be equivalent to f(b), where f denotes a function that reads only comparison-salient state that is accessible via the argument's public const members. In other words, equivalent values may be distinguishable.
std::weak_equality is the weakest comparison category type: it is not implicitly-convertible to any other comparison category, but the other four comparison categories (std::strong_equality, std::partial_ordering, std::weak_ordering, std::strong_ordering) are implicitly-convertible to std::weak_equality.
Constants
The type std::weak_equality has only two valid values, implemented as const static data members of its type: std::weak_equality::equivalent and std::weak_equality::nonequivalent:
Member constant Definition
equivalent(inline constexpr) a valid value of the type std::weak_equality indicating equivalence
[static]
nonequivalent(inline constexpr) a valid value of the type std::weak_equality indicating non-equivalence
[static]
Comparisons
Comparison operators are defined between values of this type and literal 0. This supports the expressions a <=> b == 0 and a <=> b != 0 used to convert the result of a three-way comparison operator to a boolean relationship; see std::is_eq and std::is_neq.
The behavior of a program that attempts to compare a weak_equality with anything other than the integer literal 0 is undefined.
operator== compares with zero
operator!= (function)
operator<=>
operator==
friend constexpr bool operator==(weak_equality v, /*unspecified*/ u) noexcept;
friend constexpr bool operator==(/*unspecified*/ u, weak_equality v) noexcept;
Parameters
v - a std::weak_equality value to check
u - an unused parameter of any type that accepts literal zero argument
Return value
true if v is equivalent, false if v is nonequivalent
operator!=
friend constexpr bool operator!=(weak_equality v, /*unspecified*/ u) noexcept;
friend constexpr bool operator!=(/*unspecified*/ u, weak_equality v) noexcept;
Parameters
v - a std::weak_equality value to check
u - an unused parameter of any type that accepts literal zero argument
Return value
false if v is equivalent, and true if v is nonequivalent
operator<=>
friend constexpr weak_equality operator<=>(weak_equality v, /*unspecified*/ u) noexcept;
friend constexpr weak_equality operator<=>(/*unspecified*/ u, weak_equality v) noexcept;
Parameters
v - a std::weak_equality value to check
u - an unused parameter of any type that accepts literal zero argument
Return value
v
Example
This section is incomplete
Reason: no example
See also
strong_ordering the result type of 3-way comparison that supports all 6 operators and is substitutable
(C++20)
weak_ordering the result type of 3-way comparison that supports all 6 operators and is not substitutable
(C++20)
partial_ordering the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values
(C++20)
strong_equality the result type of 3-way comparison that supports only equality/inequality and is substitutable
(C++20)