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