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(int, char**) { 26 { 27 m.lock(); 28 std::lock_guard<std::mutex> lg(m, std::adopt_lock); 29 assert(m.try_lock() == false); 30 } 31 32 m.lock(); 33 m.unlock(); 34 35 return 0; 36 } 37