#include <iostream>using namespace std; struct Base { void foo();}; struct Derived : Base {}; template<typename T, T thing>struct bar {}; template<typename T>void foo() { bar<void (T::*)(), &T::foo>{};} int main() { foo<Base>(); // Works foo<Derived>(); // Error}
Standard input is empty
prog.cpp: In instantiation of ‘void foo() [with T = Derived]’: prog.cpp:20:15: required from here prog.cpp:15:2: error: could not convert template argument ‘&Base::foo’ to ‘void (Derived::*)()’ bar<void (T::*)(), &T::foo>{}; ^~~
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!