Namespaces
Variants

std::unique_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
unique_lock & operator = ( unique_lock && other ) noexcept ;
(C++11 이후)

이동 할당 연산자. 다음 코드와 동일합니다: unique_lock { std :: move ( other ) } . swap ( * this ) ; return * this ; .

만약 other * this 와 동일한 객체라면, 아무런 효과가 없습니다. 그렇지 않고 호출 전에 * this 가 연결된 뮤텍스를 가지고 있으며 그 소유권을 획득한 상태라면, 뮤텍스가 잠금 해제됩니다.

목차

매개변수

other - 상태를 대체할 또 다른 unique_lock

반환값

* this

참고 사항

재귀적 뮤텍스의 경우 할당 전에 * this other 모두 동일한 뮤텍스를 소유할 수 있습니다. 이러한 경우 할당 후에는 * this 가 뮤텍스를 소유하게 되며 other 는 소유하지 않게 됩니다.

이동 할당은 정의되지 않은 동작을 유발할 수 있습니다. 예를 들어, * this std::adopt_lock 으로 생성되었지만 호출 스레드가 관련 뮤텍스의 소유권을 가지고 있지 않은 경우, 관련 뮤텍스의 소유권이 적절하게 해제될 수 없습니다.

결함 보고서

다음 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2104 C++11 이동 할당 연산자가 noexcept 이었지만 정의되지 않은 동작을 가질 수 있었음 noexcept 제거됨
LWG 4172 C++11 LWG2104 noexcept 을 제거함
unique_lock 의 자기 이동 할당이 잘못 명시됨
noexcept 복원됨
no-op로 재명시됨