xref: /aosp_15_r20/external/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
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 // scoped_lock(scoped_lock const&) = delete;
18 
19 #include <mutex>
20 #include "test_macros.h"
21 
main()22 int main()
23 {
24     using M = std::mutex;
25     M m0, m1, m2;
26     {
27         using LG = std::scoped_lock<>;
28         const LG Orig;
29         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
30     }
31     {
32         using LG = std::scoped_lock<M>;
33         const LG Orig(m0);
34         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
35     }
36     {
37         using LG = std::scoped_lock<M, M>;
38         const LG Orig(m0, m1);
39         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
40     }
41     {
42         using LG = std::scoped_lock<M, M, M>;
43         const LG Orig(m0, m1, m2);
44         LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}}
45     }
46 }
47