Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/explicit6.C

raw
1 // P0892R2
2 // { dg-do compile }
3 // { dg-options "-std=c++2a" }
4
5 template<int T = 1>
6 struct S {
7 explicit(T) operator int();
8 };
9
10 template<typename T, int N>
11 struct R {
12 explicit(N) operator T();
13 };
14
15 template<typename T>
16 struct U {
17 explicit((T) 1.0) operator T();
18 };
19
20 int
21 main ()
22 {
23 S s;
24 int i1 = s; // { dg-error "cannot convert" }
25 S<true> s2;
26 int i2 = s2; // { dg-error "cannot convert" }
27 S<false> s3;
28 int i3 = s3;
29 int i4{s};
30 int i5{s2};
31 int i6{s3};
32
33 R<int, true> r;
34 int i7 = r; // { dg-error "cannot convert" }
35 R<int, false> r2;
36 int i8 = r2;
37
38 U<int> u;
39 int i9 = u; // { dg-error "cannot convert" }
40 int i10{u};
41 }