命名空间
变体
操作

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

来自 cppreference.cn
 
 
 
协程支持
协程特性
协程句柄
空操作协程
平凡可等待对象
范围生成器
(C++23)
 
 
定义于头文件 <coroutine>
constexpr bool
    operator==( std::coroutine_handle<> x, std::coroutine_handle<> y ) noexcept;
(1) (自 C++20 起)
constexpr std::strong_ordering
    operator<=>( std::coroutine_handle<> x, std::coroutine_handle<> y ) noexcept;
(2) (自 C++20 起)

根据其底层地址比较两个 std::coroutine_handle<>xy

<<=>>=!= 运算符分别从 合成operator<=>operator==

内容

[edit] 参数

x, y - std::coroutine_handle<> 要比较的值

[edit] 返回值

1) x.address() == y.address()
2) std::compare_three_way{}(x.address(), y.address())

[edit] 注意

尽管这些运算符仅为 std::coroutine_handle<> 重载,但 std::coroutine_handle 的其他特化也具有相等可比性和三路可比性,因为它们可以隐式转换为 std::coroutine_handle<>

[edit] 示例