Namespaces
Variants

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

来自 zh.cppreference.net
 
 
 
协程支持
协程特征
协程句柄
无操作协程
平凡可等待对象
范围生成器
(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<>值x和y。

运算符<、<=、>、>=和!=分别合成自operator<=>和operator==。

参数

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

返回值

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

注释

尽管这些运算符仅针对 std:: coroutine_handle <> 进行了重载,但 std::coroutine_handle 的其他特化版本同样支持相等比较和三路比较,因为它们可隐式转换为 std:: coroutine_handle <> 。

示例