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 10 // UNSUPPORTED: c++03, c++11 11 12 // dylib support for shared_mutex was added in macosx10.12 13 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}} 14 15 // <shared_mutex> 16 17 // template <class Mutex> class shared_lock; 18 19 // shared_lock& operator=(shared_lock&& u); 20 21 #include <shared_mutex> 22 #include <cassert> 23 #include "nasty_containers.h" 24 25 #include "test_macros.h" 26 27 28 int main(int, char**) 29 { 30 { 31 typedef std::shared_timed_mutex M; 32 M m0; 33 M m1; 34 std::shared_lock<M> lk0(m0); 35 std::shared_lock<M> lk1(m1); 36 lk1 = std::move(lk0); 37 assert(lk1.mutex() == std::addressof(m0)); 38 assert(lk1.owns_lock() == true); 39 assert(lk0.mutex() == nullptr); 40 assert(lk0.owns_lock() == false); 41 } 42 { 43 typedef nasty_mutex M; 44 M m0; 45 M m1; 46 std::shared_lock<M> lk0(m0); 47 std::shared_lock<M> lk1(m1); 48 lk1 = std::move(lk0); 49 assert(lk1.mutex() == std::addressof(m0)); 50 assert(lk1.owns_lock() == true); 51 assert(lk0.mutex() == nullptr); 52 assert(lk0.owns_lock() == false); 53 } 54 55 return 0; 56 } 57