xref: /llvm-project/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.verify.cpp (revision b82dcb624e6bfa58ed566511cb564f8f201fa62e)
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, c++14
11 
12 // <mutex>
13 
14 // template <class ...Mutex> class scoped_lock;
15 
16 // scoped_lock(scoped_lock const&) = delete;
17 
18 #include <mutex>
19 #include "test_macros.h"
20 
main(int,char **)21 int main(int, char**)
22 {
23     using M = std::mutex;
24     M m0, m1, m2;
25     {
26         using LG = std::scoped_lock<>;
27         const LG Orig;
28         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
29     }
30     {
31         using LG = std::scoped_lock<M>;
32         const LG Orig(m0);
33         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
34     }
35     {
36         using LG = std::scoped_lock<M, M>;
37         const LG Orig(m0, m1);
38         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
39     }
40     {
41         using LG = std::scoped_lock<M, M, M>;
42         const LG Orig(m0, m1, m2);
43         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
44     }
45 
46   return 0;
47 }
48