Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/nontype-class64.C

raw
1 // Testcase from P2308R1
2 // { dg-do compile { target c++20 } }
3
4 template<auto n> struct B { /* ... */ };
5 B<5> b1; // OK, template parameter type is int
6 B<'a'> b2; // OK, template parameter type is char
7 B<2.5> b3; // OK, template parameter type is double
8 B<void(0)> b4; // { dg-error "void" }
9
10 template<int i> struct C { /* ... */ };
11 C<{ 42 }> c1; // OK
12
13 struct J1 {
14 J1 *self=this;
15 };
16 B<J1{}> j1; // { dg-error "not a constant expression" }
17
18 struct J2 {
19 J2 *self=this;
20 constexpr J2() {}
21 constexpr J2(const J2&) {}
22 };
23 B<J2{}> j2; // { dg-error "" }