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 lock_guard;
12
13// explicit lock_guard(mutex_type& m);
14
15#include <cassert>
16#include <mutex>
17#include <type_traits>
18
19#include "types.h"
20
21int main(int, char**) {
22 MyMutex m;
23 assert(!m.locked);
24 std::lock_guard<MyMutex> lg(m);
25 assert(m.locked);
26
27 static_assert(!std::is_convertible<MyMutex, std::lock_guard<MyMutex> >::value, "constructor must be explicit");
28
29 return 0;
30}
31

source code of libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/ctor.mutex.pass.cpp