template<bool Condition, typename T = void>struct EnableIf{};template<typename T>struct EnableIf<true, T>{ typedef T Type;}; struct Base{ static const int Foo = 0;}; template<int KeySize>struct Derived : public EnableIf<true || KeySize == 42, Base>::Type{ static const int Bar = Foo;}; int main(){ Derived<42> Inst;}
Standard input is empty
prog.cpp:19:25: error: ‘Foo’ was not declared in this scope static const int Bar = Foo; ^ prog.cpp: In function ‘int main()’: prog.cpp:24:14: warning: unused variable ‘Inst’ [-Wunused-variable] Derived<42> Inst; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!