• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // mutex_type *mutex() const noexcept;
22 
23 #include <shared_mutex>
24 #include <cassert>
25 
26 #include "test_macros.h"
27 
28 std::shared_timed_mutex m;
29 
main(int,char **)30 int main(int, char**)
31 {
32     std::shared_lock<std::shared_timed_mutex> lk0;
33     assert(lk0.mutex() == nullptr);
34     std::shared_lock<std::shared_timed_mutex> lk1(m);
35     assert(lk1.mutex() == &m);
36     lk1.unlock();
37     assert(lk1.mutex() == &m);
38     static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");
39 
40   return 0;
41 }
42