Namespaces
Variants

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

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
定义于头文件 <memory>
比较两个 indirect 对象
template < class U, class A >

constexpr bool operator == ( const indirect & lhs, const indirect < U, A > & rhs )

noexcept ( noexcept ( * lhs == * rhs ) ) ;
(1) (C++26 起)
template < class U, class A >

constexpr /*synth-three-way-result*/ < T, U >

operator <=> ( const indirect & lhs, const indirect < U, A > & rhs ) ;
(2) (C++26 起)
比较 indirect 对象与值
template < class U >

constexpr bool operator == ( const indirect & ind, const U & value )

noexcept ( noexcept ( * lhs == value ) ) ;
(3) (C++26 起)
template < class U >

constexpr /*synth-three-way-result*/ < T, U >

operator <=> ( const indirect & ind, const U & value ) ;
(4) (C++26 起)

indirect 对象执行比较操作。

关于 /*synth-three-way-result*/ 的定义,请参见 synth-three-way-result 。

1,2) 比较两个 indirect 对象,比较结果定义如下:
lhs 无值状态 非无值状态
rhs 无值状态 非无值状态 无值状态 非无值状态
operator == true false false * lhs == * rhs
operator <=> ! lhs. valueless_after_move ( ) <=>
! rhs. valueless_after_move ( )
synth-three-way
( * lhs, * rhs )
1) 如果表达式 * lhs == * rhs 的格式不正确,或其结果无法转换为 bool ,则程序格式不正确。
3,4) indirect 对象与值进行比较,比较结果定义如下:
运算符 ind 为无值状态 ind 非无值状态
operator == false * ind == value
operator <=> std :: strong_ordering :: less synth-three-way  ( * ind, value )
3) 如果表达式 * ind == value 的格式不正确,或其结果无法转换为 bool ,则程序格式不正确。

参数

lhs, rhs, ind - 要比较的 indirect 对象
value - 与所持有值进行比较的值

返回值

如上所述。

示例