Debian Codegraph @

libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/ctor.adopt_lock.pass.cpp

raw
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: c++03
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 <cassert>
19
20 #include "types.h"
21
22 int main(int, char**) {
23 MyMutex m;
24 {
25 m.lock();
26 std::lock_guard<MyMutex> lg(m, std::adopt_lock);
27 assert(m.locked);
28 }
29 assert(!m.locked);
30
31 return 0;
32 }