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 // explicit operator bool() const noexcept;
22 
23 #include <shared_mutex>
24 #include <cassert>
25 
26 #include "test_macros.h"
27 
28 std::shared_timed_mutex m;
29 
30 int main(int, char**)
31 {
32     std::shared_lock<std::shared_timed_mutex> lk0;
33     assert(static_cast<bool>(lk0) == false);
34     std::shared_lock<std::shared_timed_mutex> lk1(m);
35     assert(static_cast<bool>(lk1) == true);
36     lk1.unlock();
37     assert(static_cast<bool>(lk1) == false);
38     static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept");
39 
40   return 0;
41 }
42