55 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++03, c++11, c++1411 12// <mutex>13 14// template <class ...Mutex> class scoped_lock;15 16// explicit scoped_lock(Mutex&...);17 18#include <mutex>19#include "test_macros.h"20 21template <class LG>22void test_conversion(LG) {}23 24int main(int, char**)25{26 using M = std::mutex;27 M m0, m1, m2;28 M n0, n1, n2;29 {30 using LG = std::scoped_lock<>;31 LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}}32 test_conversion<LG>({}); // expected-error{{no matching function for call}}33 ((void)lg);34 }35 {36 using LG = std::scoped_lock<M>;37 LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}}38 test_conversion<LG>({n0}); // expected-error{{no matching function for call}}39 ((void)lg);40 }41 {42 using LG = std::scoped_lock<M, M>;43 LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}}44 test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}}45 ((void)lg);46 }47 {48 using LG = std::scoped_lock<M, M, M>;49 LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}}50 test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}}51 }52 53 return 0;54}55