//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template class unique_lock; // explicit operator bool() const noexcept; #include #include #include #include "checking_mutex.h" #include "test_macros.h" #if TEST_STD_VER >= 11 static_assert(noexcept(static_cast(std::declval&>())), ""); #endif int main(int, char**) { static_assert(std::is_constructible >::value, ""); static_assert(!std::is_convertible, bool>::value, ""); checking_mutex mux; const std::unique_lock lk0; // Make sure `operator bool()` is `const` assert(!static_cast(lk0)); std::unique_lock lk1(mux); assert(static_cast(lk1)); lk1.unlock(); assert(!static_cast(lk1)); ASSERT_NOEXCEPT(static_cast(lk0)); return 0; }