Namespaces
Variants

std::jthread:: operator=

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
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