1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-threads
10 // UNSUPPORTED: c++03, c++11
14 // template <class Mutex> class shared_lock;
16 // explicit operator bool() const noexcept;
18 #include <shared_mutex>
20 #include <type_traits>
22 #include "test_macros.h"
26 void unlock_shared() {}
31 static_assert(std::is_constructible
<bool, std::shared_lock
<M
>>::value
, "");
32 static_assert(!std::is_convertible
<std::shared_lock
<M
>, bool>::value
, "");
35 std::shared_lock
<M
> lk0
;
36 assert(static_cast<bool>(lk0
) == false);
37 std::shared_lock
<M
> lk1(m
);
38 assert(static_cast<bool>(lk1
) == true);
40 assert(static_cast<bool>(lk1
) == false);
41 ASSERT_NOEXCEPT(static_cast<bool>(lk0
));