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: no-threads 10 // UNSUPPORTED: c++03, c++11 11 12 // <shared_mutex> 13 14 // template <class Mutex> class shared_lock; 15 16 // shared_lock(mutex_type& m, defer_lock_t); 17 18 #include <shared_mutex> 19 #include <cassert> 20 #include <mutex> 21 #include "nasty_containers.h" 22 23 #include "test_macros.h" 24 main(int,char **)25int main(int, char**) 26 { 27 { 28 typedef std::shared_timed_mutex M; 29 M m; 30 std::unique_lock<M> lk(m, std::defer_lock); 31 assert(lk.mutex() == std::addressof(m)); 32 assert(lk.owns_lock() == false); 33 } 34 { 35 typedef nasty_mutex M; 36 M m; 37 std::unique_lock<M> lk(m, std::defer_lock); 38 assert(lk.mutex() == std::addressof(m)); 39 assert(lk.owns_lock() == false); 40 } 41 42 return 0; 43 } 44