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++98, c++03, c++11
11 // XFAIL: dylib-has-no-shared_mutex
12 
13 // <shared_mutex>
14 
15 // template <class Mutex> class shared_lock;
16 
17 // mutex_type *mutex() const noexcept;
18 
19 #include <shared_mutex>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 std::shared_timed_mutex m;
25 
26 int main(int, char**)
27 {
28     std::shared_lock<std::shared_timed_mutex> lk0;
29     assert(lk0.mutex() == nullptr);
30     std::shared_lock<std::shared_timed_mutex> lk1(m);
31     assert(lk1.mutex() == &m);
32     lk1.unlock();
33     assert(lk1.mutex() == &m);
34     static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");
35 
36   return 0;
37 }
38