1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: libcpp-has-no-threads 11 // UNSUPPORTED: c++98, c++03, c++11, c++14 12 13 // <mutex> 14 15 // template <class ...Mutex> class scoped_lock; 16 17 // explicit scoped_lock(Mutex&...); 18 19 #include <mutex> 20 #include "test_macros.h" 21 22 template <class LG> 23 void test_conversion(LG) {} 24 25 int main() 26 { 27 using M = std::mutex; 28 M m0, m1, m2; 29 M n0, n1, n2; 30 { 31 using LG = std::scoped_lock<>; 32 LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}} 33 test_conversion<LG>({}); // expected-error{{no matching function for call}} 34 ((void)lg); 35 } 36 { 37 using LG = std::scoped_lock<M>; 38 LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}} 39 test_conversion<LG>({n0}); // expected-error{{no matching function for call}} 40 ((void)lg); 41 } 42 { 43 using LG = std::scoped_lock<M, M>; 44 LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}} 45 test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}} 46 ((void)lg); 47 } 48 { 49 using LG = std::scoped_lock<M, M, M>; 50 LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}} 51 test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}} 52 } 53 } 54