1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | template <class T> struct impl { void f(T &) { } void f(T *) { } }; template <class T> void g(T & v) { impl<T>::f(v); } int main() { g(main); } |
dGVtcGxhdGUgPGNsYXNzIFQ+CnN0cnVjdCBpbXBsCnsKICAgdm9pZCBmKFQgJikKICAgewogICB9CiAgIHZvaWQgZihUICopCiAgIHsKICAgfQp9OwoKdGVtcGxhdGUgPGNsYXNzIFQ+CnZvaWQgZyhUICYgdikKewogICAgaW1wbDxUPjo6Zih2KTsKfQoKaW50IG1haW4oKQp7CiAgICBnKG1haW4pOwp9Cg==
prog.cpp: In function ‘void g(T&) [with T = int ()()]’: prog.cpp:20: instantiated from here prog.cpp:15: error: call of overloaded ‘f(int (&)())’ is ambiguous prog.cpp:4: note: candidates are: void impl<T>::f(T&) [with T = int ()()] prog.cpp:7: note: void impl<T>::f(T*) [with T = int ()()]
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


