enum-unscoped-nonexistent.cpp [plain text]
struct Base {
static const int a = 1;
};
template<typename T> struct S : Base {
enum E : int;
constexpr int f();
constexpr int g(); void h();
};
template<> enum S<char>::E : int {}; template<> enum S<short>::E : int { b = 2 };
template<> enum S<int>::E : int { a = 4 };
template<typename T> enum S<T>::E : int { b = 8 };
template<typename T> constexpr int S<T>::f() { return a; }
static_assert(S<char>().f() == 1, "");
static_assert(S<int>().f() == 1, "");
template<typename T> constexpr int S<T>::g() { return b; } static_assert(S<char>().g() == 1, ""); static_assert(S<short>().g() == 2, "");
static_assert(S<long>().g() == 8, "");
template<typename T> void S<T>::h() {
char c[S<T>::b];
static_assert(b != 8, "");
static_assert(sizeof(c) != 8, "");
}
void f() {
S<short>().h(); }