1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // UNSUPPORTED: no-threads, c++03 10 11 // <mutex> 12 13 // template <class Mutex> class unique_lock; 14 15 // unique_lock& operator=(unique_lock&& u); 16 17 #include <mutex> 18 #include <cassert> 19 #include "nasty_containers.h" 20 21 #include "test_macros.h" 22 main(int,char **)23int main(int, char**) 24 { 25 { 26 typedef std::mutex M; 27 M m0; 28 M m1; 29 std::unique_lock<M> lk0(m0); 30 std::unique_lock<M> lk1(m1); 31 lk1 = std::move(lk0); 32 assert(lk1.mutex() == std::addressof(m0)); 33 assert(lk1.owns_lock() == true); 34 assert(lk0.mutex() == nullptr); 35 assert(lk0.owns_lock() == false); 36 } 37 { 38 typedef nasty_mutex M; 39 M m0; 40 M m1; 41 std::unique_lock<M> lk0(m0); 42 std::unique_lock<M> lk1(m1); 43 lk1 = std::move(lk0); 44 assert(lk1.mutex() == std::addressof(m0)); 45 assert(lk1.owns_lock() == true); 46 assert(lk0.mutex() == nullptr); 47 assert(lk0.owns_lock() == false); 48 } 49 50 return 0; 51 } 52