1 // P0892R2
2 // { dg-do compile }
3 // { dg-options "-std=c++2a" }
4
fn0()5 constexpr int fn0 () { return 0; }
fn1()6 constexpr int fn1 () { return 1; }
7
8 struct S {
9 explicit(true) S(int);
10 explicit(1 == 0) S(int, int);
11 explicit(fn0()) S(int, int, int);
12 explicit(fn1()) S(int, int, int, int);
13 };
14
15 struct X {
16 static const bool value = true;
fooX17 static constexpr bool foo () { return 1; }
18 };
19
20 struct T {
21 explicit(true ? 1 : throw 1) T(int);
22 explicit(true || true ? 1 : throw 1) T(int, int);
23 explicit(X::value) T(int, int, int);
24 explicit(X::foo ()) T(int, int, int, int);
25 };
26
27 struct W {
28 constexpr operator bool() { return true; };
29 };
30
31 struct W2 {
32 constexpr operator bool() { return false; };
33 };
34
35 struct U {
36 explicit(W()) U(int);
37 explicit(W2()) U(int, int);
38 };
39
40 int
main()41 main ()
42 {
43 S s1 = { 1 }; // { dg-error "converting" }
44 S s1x{ 1 };
45 S s2 = { 2, 3 };
46 S s3 = { 4, 5, 6 };
47 S s4 = { 7, 8, 9, 10 }; // { dg-error "converting" }
48 S s4x{ 7, 8, 9, 10 };
49
50 T t1 = { 1 }; // { dg-error "converting" }
51 T t2 = { 1, 2 }; // { dg-error "converting" }
52 T t3 = { 1, 2, 3 }; // { dg-error "converting" }
53 T t4 = { 1, 2, 3, 4 }; // { dg-error "converting" }
54 T t5{ 1 };
55 T t6{ 1, 2 };
56 T t7{ 1, 2, 3 };
57 T t8{ 1, 2, 3, 4 };
58
59 U u1 = { 1 }; // { dg-error "converting" }
60 U u2{ 1 };
61 U u3 = { 1, 2 };
62 U u4 { 1, 2 };
63 }
64