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 // UNSUPPORTED: libcpp-has-no-threads
10 
11 // <mutex>
12 
13 // template <class Mutex> class lock_guard;
14 
15 // explicit lock_guard(mutex_type& m);
16 
17 // template<class _Mutex> lock_guard(lock_guard<_Mutex>)
18 //     -> lock_guard<_Mutex>;  // C++17
19 
20 #include <mutex>
21 #include <cstdlib>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
26 std::mutex m;
27 
28 int main()
29 {
30   {
31     std::lock_guard<std::mutex> lg(m);
32     assert(m.try_lock() == false);
33   }
34 
35   m.lock();
36   m.unlock();
37 
38 #ifdef __cpp_deduction_guides
39   std::lock_guard lg(m);
40   static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" );
41 #endif
42 
43   return 0;
44 }
45