Namespaces
Variants
Actions

std::shared_lock<Mutex>::operator=

From cppreference.com
< cpp‎ | thread‎ | shared lock
 
C++
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
(C++11)
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
Safe reclamation
(C++26)
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::shared_lock
shared_lock& operator=( shared_lock&& other ) noexcept;
(since C++14)

Move assignment operator. Equivalent to shared_lock{std::move(other)}.swap(*this); return *this;.

If other is the same object as *this, there is no effect.

Otherwise, if prior to this call *this has an associated mutex ((mutex() returns a non-null pointer) and has acquired ownership of it (owns() returns true), the mutex is unlocked by calling unlock_shared(). After this call, other has no associated mutex.

[edit] Parameters

other - another shared_lock to replace the state with

[edit] Return value

*this

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 4172 C++14 self-move-assignment of shared_lock was incorrectly specified respecified as no-op

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant