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++98, c++03
10 
11 // Before GCC 6, aggregate initialization kicks in.
12 // See https://stackoverflow.com/q/41799015/627587.
13 // UNSUPPORTED: gcc-5
14 
15 // <utility>
16 
17 // template <class T1, class T2> struct pair
18 
19 // explicit(see-below) constexpr pair();
20 
21 // This test checks the conditional explicitness of std::pair's default
22 // constructor as introduced by the resolution of LWG 2510.
23 
24 #include <utility>
25 
26 
27 struct ImplicitlyDefaultConstructible {
28     ImplicitlyDefaultConstructible() = default;
29 };
30 
31 struct ExplicitlyDefaultConstructible {
32     explicit ExplicitlyDefaultConstructible() = default;
33 };
34 
35 std::pair<ImplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
36 std::pair<ExplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
37 std::pair<ExplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}
38 std::pair<ImplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test4() { return {}; }
39 
40 int main(int, char**) {
41     return 0;
42 }
43