Namespaces
Variants

std::shared_lock<Mutex>:: 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
shared_lock & operator = ( shared_lock && other ) noexcept ;
(自 C++14 起)

移动赋值运算符。等价于 shared_lock { std :: move ( other ) } . swap ( * this ) ; return * this ;

如果 other * this 是同一对象,则无任何效果。

否则,若在此调用前 * this 已关联互斥量( mutex() 返回非空指针)且已获得其所有权( owns() 返回 true ),则通过调用 unlock_shared() 解锁该互斥量。此调用后, other 不再关联任何互斥量。

参数

其他 - 用于替换状态的另一个 shared_lock

返回值

* this

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

问题报告 应用于 发布时的行为 正确行为
LWG 4172 C++14 shared_lock 的自移动赋值规范存在错误 重新规范为无操作