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: c++03, c++11, c++14 |
10 | |
11 | // <variant> |
12 | |
13 | // LWG issue 3024 |
14 | |
15 | #include <variant> |
16 | #include <type_traits> |
17 | |
18 | struct NotCopyConstructible |
19 | { |
20 | NotCopyConstructible() = default; |
21 | NotCopyConstructible(NotCopyConstructible const&) = delete; |
22 | }; |
23 | |
24 | int main(int, char**) |
25 | { |
26 | static_assert(!std::is_copy_constructible_v<NotCopyConstructible>); |
27 | |
28 | std::variant<NotCopyConstructible> v; |
29 | std::variant<NotCopyConstructible> v1; |
30 | std::variant<NotCopyConstructible> v2(v); // expected-error {{call to implicitly-deleted copy constructor of 'std::variant<NotCopyConstructible>'}} |
31 | v1 = v; // expected-error-re {{object of type 'std:{{.*}}:variant<NotCopyConstructible>' cannot be assigned because its copy assignment operator is implicitly deleted}} |
32 | } |
33 | |