命名空间
变体
操作

std::jthread::operator=

来自 cppreference.cn
< cpp‎ | thread‎ | jthread
 
 
并发支持库
线程
(C++11)
(C++20)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
协作式取消
互斥
(C++11)
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
条件变量
(C++11)
信号量
闩锁和屏障
(C++20)
(C++20)
期物
(C++11)
(C++11)
(C++11)
(C++11)
安全回收
(C++26)
Hazard 指针
原子类型
(C++11)
(C++20)
原子类型的初始化
(C++11)(C++20 中已弃用)
(C++11)(C++20 中已弃用)
内存顺序
(C++11)(C++26 中已弃用)
原子操作的自由函数
原子标志的自由函数
 
 
std::jthread& operator=( std::jthread&& other ) noexcept;
(since C++20)

如果 *this 仍然有一个关联的运行线程(即 joinable() == true),则调用 request_stop(),然后调用 join()。 将 other 的状态赋值给 *this,并将 other 设置为默认构造状态。

在此调用之后,this->get_id() 等于调用前 other.get_id() 的值,并且关联的停止状态也被移动,而 other 不再表示执行线程,也不再具有任何停止状态。

[编辑] 参数

other - 要赋值给此 jthread 对象的另一个 jthread 对象

[编辑] 返回值

*this