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(int, char**) { 29 { 30 std::lock_guard<std::mutex> lg(m); 31 assert(m.try_lock() == false); 32 } 33 34 m.lock(); 35 m.unlock(); 36 37 #ifdef __cpp_deduction_guides 38 std::lock_guard lg(m); 39 static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" ); 40 #endif 41 42 return 0; 43 } 44