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 // <shared_mutex>
13 
14 // template <class Mutex> class shared_lock;
15 
16 // shared_lock(shared_lock&& u);
17 
18 #include <shared_mutex>
19 #include <cassert>
20 #include "nasty_containers.h"
21 
22 #include "test_macros.h"
23 
main(int,char **)24 int main(int, char**)
25 {
26     {
27     typedef std::shared_timed_mutex M;
28     M m;
29     std::shared_lock<M> lk0(m);
30     std::shared_lock<M> lk = std::move(lk0);
31     assert(lk.mutex() == std::addressof(m));
32     assert(lk.owns_lock() == true);
33     assert(lk0.mutex() == nullptr);
34     assert(lk0.owns_lock() == false);
35     }
36     {
37     typedef nasty_mutex M;
38     M m;
39     std::shared_lock<M> lk0(m);
40     std::shared_lock<M> lk = std::move(lk0);
41     assert(lk.mutex() == std::addressof(m));
42     assert(lk.owns_lock() == true);
43     assert(lk0.mutex() == nullptr);
44     assert(lk0.owns_lock() == false);
45     }
46 
47   return 0;
48 }
49