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

定义于头文件 <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== 合成

参数

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<>

示例