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 //===----------------------------------------------------------------------===//
8 
9 // <mutex>
10 
11 // template <class Mutex> class unique_lock;
12 
13 // explicit unique_lock(mutex_type& m);
14 
15 // template<class _Mutex> unique_lock(unique_lock<_Mutex>)
16 //     -> unique_lock<_Mutex>;  // C++17
17 
18 #include <cassert>
19 #include <mutex>
20 
21 #include "checking_mutex.h"
22 #include "test_macros.h"
23 
24 int main(int, char**) {
25   checking_mutex mux;
26 
27   {
28     std::unique_lock<checking_mutex> lock(mux);
29     assert(mux.current_state == checking_mutex::locked_via_lock);
30   }
31   assert(mux.current_state == checking_mutex::unlocked);
32 
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
36 
37   return 0;
38 }
39