operator==, <=>(std::indirect)
来自cppreference.com
| 在标头 <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 无值
|
lhs 有值
| ||
|---|---|---|---|---|
rhs 无值
|
rhs 有值
|
rhs 无值
|
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 | - | 与拥有的值比较的值 |
返回值
如上所述。
示例
| 本节未完成 原因:暂无示例 |