| 1 |
// { dg-do compile { target c++14 } } |
| 2 |
|
| 3 |
// Template variables and static member variables of template classes are |
| 4 |
// often confused. |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
struct S1 |
| 8 |
{ |
| 9 |
static int n; |
| 10 |
static int arr[]; |
| 11 |
}; |
| 12 |
|
| 13 |
template<typename T> |
| 14 |
constexpr int var = sizeof (T); |
| 15 |
|
| 16 |
template<typename T> |
| 17 |
int S1<T>::n = sizeof (T); |
| 18 |
|
| 19 |
template<typename T> |
| 20 |
int S1<T>::arr[sizeof (T)]; |
| 21 |
|
| 22 |
template<> |
| 23 |
int S1<int>::n = 8; |
| 24 |
|
| 25 |
template<> |
| 26 |
int S1<int>::arr[8]; |
| 27 |
|
| 28 |
int main () |
| 29 |
{ |
| 30 |
S1<int> v1; |
| 31 |
var<S1<int>>; |
| 32 |
return 0; |
| 33 |
} |