[CodeGen][NewPM] Port GCNPreRALongBranchReg to NPM. (#125844)
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.obs / op_bool.pass.cpp
blob3542a40d25d39e2b1319c077aa186b6019faec88
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 //===----------------------------------------------------------------------===//
9 // <mutex>
11 // template <class Mutex> class unique_lock;
13 // explicit operator bool() const noexcept;
15 #include <cassert>
16 #include <mutex>
17 #include <type_traits>
19 #include "checking_mutex.h"
20 #include "test_macros.h"
22 #if TEST_STD_VER >= 11
23 static_assert(noexcept(static_cast<bool>(std::declval<std::unique_lock<checking_mutex>&>())), "");
24 #endif
26 int main(int, char**) {
27 static_assert(std::is_constructible<bool, std::unique_lock<checking_mutex> >::value, "");
28 static_assert(!std::is_convertible<std::unique_lock<checking_mutex>, bool>::value, "");
30 checking_mutex mux;
31 const std::unique_lock<checking_mutex> lk0; // Make sure `operator bool()` is `const`
32 assert(!static_cast<bool>(lk0));
33 std::unique_lock<checking_mutex> lk1(mux);
34 assert(static_cast<bool>(lk1));
35 lk1.unlock();
36 assert(!static_cast<bool>(lk1));
38 ASSERT_NOEXCEPT(static_cast<bool>(lk0));
40 return 0;