1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 11 12 // <mutex> 13 14 // template <class Mutex> class unique_lock; 15 16 // unique_lock& operator=(unique_lock&& u); 17 18 #include <mutex> 19 #include <cassert> 20 #include "nasty_containers.hpp" 21 main()22int main() 23 { 24 { 25 typedef std::mutex M; 26 M m0; 27 M m1; 28 std::unique_lock<M> lk0(m0); 29 std::unique_lock<M> lk1(m1); 30 lk1 = std::move(lk0); 31 assert(lk1.mutex() == std::addressof(m0)); 32 assert(lk1.owns_lock() == true); 33 assert(lk0.mutex() == nullptr); 34 assert(lk0.owns_lock() == false); 35 } 36 { 37 typedef nasty_mutex M; 38 M m0; 39 M m1; 40 std::unique_lock<M> lk0(m0); 41 std::unique_lock<M> lk1(m1); 42 lk1 = std::move(lk0); 43 assert(lk1.mutex() == std::addressof(m0)); 44 assert(lk1.owns_lock() == true); 45 assert(lk0.mutex() == nullptr); 46 assert(lk0.owns_lock() == false); 47 } 48 } 49