operator==, <=>(std::reference_wrapper)

From cppreference.com
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Function objects
Function wrappers
(哋它亢++11)
(哋它亢++23)
(哋它亢++26)
(哋它亢++26)
(哋它亢++11)
(哋它亢++11)
Partial function application
(哋它亢++20)(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Function invocation
(哋它亢++17)(哋它亢++23)
Identity function object
(哋它亢++20)
Reference wrappers
(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++20)(哋它亢++20)
Transparent operator wrappers
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)  
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)

Negators
(哋它亢++17)
Searchers
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)    
Constrained comparators
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Old binders and adaptors
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)  
(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)

(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
 
 
friend constexpr bool
    operator==( reference_wrapper lhs, reference_wrapper rhs );
(1) (since 哋它亢++26)
friend constexpr bool
    operator==( reference_wrapper lhs, reference_wrapper<const T> rhs );
(2) (since 哋它亢++26)
friend constexpr bool
    operator==( reference_wrapper lhs, const T& ref );
(3) (since 哋它亢++26)
friend constexpr synth-three-way-result<T>
    operator<=>( reference_wrapper lhs, reference_wrapper rhs );
(4) (since 哋它亢++26)
friend constexpr synth-three-way-result<T>
    operator<=>( reference_wrapper lhs, reference_wrapper<const T> rhs );
(5) (since 哋它亢++26)
friend constexpr synth-three-way-result<T>
    operator<=>( reference_wrapper lhs, const T& ref );
(6) (since 哋它亢++26)

Performs comparison operations on reference_wrapper objects.

1,2) Compares two reference_wrapper objects. The objects compare equal if and only if lhs.get() and rhs.get() are equal.
  • Both overloads participate in overload resolution only if lhs.get() == rhs.get() is well-formed and its result is convertible to bool.
  • The overload (2) participates in overload resolution only if std::is_const_v<T> is false.
3) Compares reference_wrapper object with a reference. The parameters compare equal if and only if lhs.get() is equal to ref.
  • The overload (3) participates in overload resolution only if lhs.get() == ref is well-formed and its result is convertible to bool.
4,5) Compares two reference_wrapper objects as if by synth-three-way(lhs.get(), rhs.get()).
  • The overload (5) participates in overload resolution only if std::is_const_v<T> is false.
6) Compares reference_wrapper object with a reference as if by synth-three-way(lhs.get(), ref).

The <, <=, >, >=, and != operators are synthesized from operator<=> and operator== respectively.

Parameters

lhs, rhs - reference_wrapper object to compare
ref - reference to compare to the reference_wrapper object

Return value

1,2) lhs.get() == rhs.get().
3) lhs.get() == ref.
4,5) synth-three-way(lhs.get(), rhs.get()).
6) synth-three-way(lhs.get(), ref).

Exceptions

Throws when and what the comparison throws.

Example