命名空间
变体
操作

std::jthread::operator=

来自 cppreference.cn
< cpp‎ | thread‎ | jthread
 
 
并发支持库
线程
(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)
危险指针
原子类型
(C++11)
(C++20)
原子类型的初始化
(C++11)(C++20 中已弃用)
(C++11)(C++20 中已弃用)
内存排序
(C++11)(C++26 中已弃用)
原子操作的自由函数
原子标志的自由函数
 
 
std::jthread& operator=( std::jthread&& other ) noexcept;
(C++20 起)

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

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

[编辑] 参数

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

[编辑] 返回值

*this