[lldb] Make SBProgress move-only (#124843)
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.obs / owns_lock.pass.cpp
blob11a674a55392fee36555fe75bbc5a03ff1bef621
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 // bool owns_lock() const;
15 #include <cassert>
16 #include <mutex>
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()), "");
23 #endif
25 int main(int, char**) {
27 checking_mutex mux;
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());
32 lock1.unlock();
33 assert(!lock1.owns_lock());
36 return 0;