instantiate-static-var.cpp [plain text]
template<typename T, T Divisor>
class X {
public:
static const T value = 10 / Divisor; };
int array1[X<int, 2>::value == 5? 1 : -1];
X<int, 0> xi0;
template<typename T>
class Y {
static const T value = 0; };
Y<float> fy;
template<typename T>
struct Z {
static T value;
};
template<typename T>
T Z<T>::value;
struct DefCon {};
struct NoDefCon {
NoDefCon(const NoDefCon&); };
void test() {
DefCon &DC = Z<DefCon>::value;
NoDefCon &NDC = Z<NoDefCon>::value; }
struct X1 {
~X1(); };
template <typename T>
struct Y1 {
static char Helper(T);
static const int value = sizeof(Helper(T()));
};
struct X2 {
virtual ~X2();
};
namespace std {
class type_info { };
}
template <typename T>
struct Y2 {
static T &Helper();
static const int value = sizeof(typeid(Helper()));
};
template <int>
struct Z1 {};
void Test() {
Z1<Y1<X1>::value> x;
int y[Y1<X1>::value];
Z1<Y2<X2>::value> x2;
int y2[Y2<X2>::value];
}
template <int n>
struct X3 {};
class Y3 {
public:
~Y3();
void Foo(X3<1>);
};
template <typename T>
struct SizeOf {
static const int value = sizeof(T);
};
void MyTest3() {
Y3().Foo(X3<SizeOf<char>::value>());
}
namespace PR6449 {
template<typename T>
struct X0 {
static const bool var = false;
};
template<typename T>
const bool X0<T>::var;
template<typename T>
struct X1 : public X0<T> {
static const bool var = false;
};
template<typename T>
const bool X1<T>::var;
template class X0<char>;
template class X1<char>;
}