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 |
10 | |
11 | // <utility> |
12 | |
13 | // template <class T1, class T2> struct pair |
14 | |
15 | // explicit(see-below) constexpr pair(); |
16 | |
17 | // This test checks the conditional explicitness of std::pair's default |
18 | // constructor as introduced by the resolution of https://wg21.link/LWG2510. |
19 | |
20 | #include <utility> |
21 | |
22 | |
23 | struct ImplicitlyDefaultConstructible { |
24 | ImplicitlyDefaultConstructible() = default; |
25 | }; |
26 | |
27 | struct ExplicitlyDefaultConstructible { |
28 | explicit ExplicitlyDefaultConstructible() = default; |
29 | }; |
30 | |
31 | std::pair<ImplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}} |
32 | std::pair<ExplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}} |
33 | std::pair<ExplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}} |
34 | std::pair<ImplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test4() { return {}; } |
35 |