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