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 //===----------------------------------------------------------------------===//
11 // template <class Mutex> class unique_lock;
13 // bool owns_lock() const;
18 #include "checking_mutex.h"
19 #include "test_macros.h"
21 #if TEST_STD_VER >= 11
22 static_assert(noexcept(std::declval
<std::unique_lock
<checking_mutex
>&>().owns_lock()), "");
25 int main(int, char**) {
28 const std::unique_lock
<checking_mutex
> lock0
; // Make sure `owns_lock()` is `const`
29 assert(!lock0
.owns_lock());
30 std::unique_lock
<checking_mutex
> lock1(mux
);
31 assert(lock1
.owns_lock());
33 assert(!lock1
.owns_lock());