| 1 |
// { dg-do run { target c++11 } } |
| 2 |
|
| 3 |
struct A |
| 4 |
{ |
| 5 |
int i = 42; |
| 6 |
}; |
| 7 |
|
| 8 |
struct B |
| 9 |
{ |
| 10 |
int i = 42; |
| 11 |
B() { } |
| 12 |
B(int i): i(i) { } |
| 13 |
}; |
| 14 |
|
| 15 |
template <class T, T t> |
| 16 |
struct C |
| 17 |
{ |
| 18 |
T m = t; |
| 19 |
}; |
| 20 |
|
| 21 |
template <class T, T t> |
| 22 |
struct D |
| 23 |
{ |
| 24 |
T m = t; |
| 25 |
D() { } |
| 26 |
D(T m):m(m) { } |
| 27 |
}; |
| 28 |
|
| 29 |
int main() |
| 30 |
{ |
| 31 |
A a1; |
| 32 |
if (a1.i != 42) return 1; |
| 33 |
A a2{}; |
| 34 |
if (a2.i != 42) return 2; |
| 35 |
A a3[1]; |
| 36 |
if (a3[0].i != 42) return 3; |
| 37 |
|
| 38 |
B b1; |
| 39 |
if (b1.i != 42) return 3; |
| 40 |
B b2 (24); |
| 41 |
if (b2.i != 24) return 4; |
| 42 |
|
| 43 |
C<int,3> c1; |
| 44 |
if (c1.m != 3) return 5; |
| 45 |
C<int,5> c2 {}; |
| 46 |
if (c2.m != 5) return 6; |
| 47 |
|
| 48 |
D<int,3> d1; |
| 49 |
if (d1.m != 3) return 7; |
| 50 |
D<int,3> d2 (5) ; |
| 51 |
if (d2.m != 5) return 8; |
| 52 |
} |