std::strong_equality (3) - Linux Manuals

std::strong_equality: std::strong_equality

NAME

std::strong_equality - std::strong_equality

Synopsis


Defined in header <compare>
class strong_equality; (since C++20)


The class type std::strong_equality is the result type of a three-way_comparison that


* admits only equality and inequality comparisons (no less-than/greater-than)


* implies substitutability: if a is equivalent to b, f(a) is also 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 are indistinguishable.

Constants


The type std::strong_equality has four valid values, implemented as const static data members of its type:


Member constant Definition


equivalent(inline constexpr) a valid value of the type std::strong_equality indicating equality
                                (public static member constant)
[static]


equal(inline constexpr) a valid value of the type std::strong_equality indicating equality
                                (public static member constant)
[static]


nonequivalent(inline constexpr) a valid value of the type std::strong_equality indicating non-equality
                                (public static member constant)
[static]


nonequal(inline constexpr) a valid value of the type std::strong_equality indicating non-equality
                                (public static member constant)
[static]

Conversions


std::strong_equality is implicitly-convertible to std::weak_equality, and std::strong_ordering is implicitly-convertible to strong_equality.


                       implicit conversion to std::weak_equality
operator weak_equality (public member function)


 std::strong_equality::operator weak_equality


constexpr operator weak_equality() const noexcept;

Return value


std::weak_equality::equivalent if v is equivalent or equal, std::weak_equality::nonequivalent if v is nonequivalent or nonequal.

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 strong_equality with anything other than the integer literal 0 is undefined.


operator== compares with zero
operator!= (function)
operator<=>


 operator==


friend constexpr bool operator==(strong_equality v, /*unspecified*/ u) noexcept;
friend constexpr bool operator==(/*unspecified*/ u, strong_equality v) noexcept;

Parameters


v - a std::strong_equality value to check
u - an unused parameter of any type that accepts literal zero argument

Return value


true if v is equivalent or equal, false if v is nonequivalent or nonequal


 operator!=


friend constexpr bool operator!=(strong_equality v, /*unspecified*/ u) noexcept;
friend constexpr bool operator!=(/*unspecified*/ u, strong_equality v) noexcept;

Parameters


v - a std::strong_equality value to check
u - an unused parameter of any type that accepts literal zero argument

Return value


false if v is equivalent or equal, and true if v is nonequivalent or nonequal


 operator<=>


friend constexpr strong_equality operator<=>(strong_equality v, /*unspecified*/ u) noexcept;
friend constexpr strong_equality operator<=>(/*unspecified*/ u, strong_equality v) noexcept;

Parameters


v - a std::strong_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
                 (class)
(C++20)


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


partial_ordering the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values
                 (class)
(C++20)


weak_equality the result type of 3-way comparison that supports only equality/inequality and is not substitutable
                 (class)
(C++20)