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 // lock_guard(mutex_type& m, adopt_lock_t);
16 
17 #include <mutex>
18 #include <cstdlib>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
23 std::mutex m;
24 
25 int main()
26 {
27   {
28     m.lock();
29     std::lock_guard<std::mutex> lg(m, std::adopt_lock);
30     assert(m.try_lock() == false);
31   }
32 
33   m.lock();
34   m.unlock();
35 
36   return 0;
37 }
38