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
13 // template <class Mutex> class unique_lock;
15 // explicit operator bool() const noexcept;
19 #include <type_traits>
21 #include "test_macros.h"
27 static_assert(std::is_constructible
<bool, std::unique_lock
<std::mutex
> >::value
, "");
28 static_assert(!std::is_convertible
<std::unique_lock
<std::mutex
>, bool>::value
, "");
30 std::unique_lock
<std::mutex
> lk0
;
31 assert(static_cast<bool>(lk0
) == false);
32 std::unique_lock
<std::mutex
> lk1(m
);
33 assert(static_cast<bool>(lk1
) == true);
35 assert(static_cast<bool>(lk1
) == false);
36 ASSERT_NOEXCEPT(static_cast<bool>(lk0
));