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