[bazel] Port for baf27862ddb23c3854cb6782a3f1675da4722a50
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.cons / mutex.pass.cpp
blob31f15deec0cfafeace2d0ca723f05a08f8fc9f53
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 unique_lock(mutex_type& m);
15 // template<class _Mutex> unique_lock(unique_lock<_Mutex>)
16 // -> unique_lock<_Mutex>; // C++17
18 #include <cassert>
19 #include <mutex>
21 #include "checking_mutex.h"
22 #include "test_macros.h"
24 int main(int, char**) {
25 checking_mutex mux;
28 std::unique_lock<checking_mutex> lock(mux);
29 assert(mux.current_state == checking_mutex::locked_via_lock);
31 assert(mux.current_state == checking_mutex::unlocked);
33 #if TEST_STD_VER >= 17
34 static_assert(std::is_same_v<std::unique_lock<checking_mutex>, decltype(std::unique_lock{mux})>, "");
35 #endif
37 return 0;