1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> namespace A { int f(int); template<class T> int g(T x) { return f(x); } } namespace B { struct C {}; } namespace A { int f(B::C x) { return 1; } } int h() { return A::g(B::C()); } int main() { std::cout << h(); } |
I2luY2x1ZGUgPGlvc3RyZWFtPgoKbmFtZXNwYWNlIEEgeyBpbnQgZihpbnQpOyB0ZW1wbGF0ZTxjbGFzcyBUPiBpbnQgZyhUIHgpIHsgcmV0dXJuIGYoeCk7IH0gfQoKbmFtZXNwYWNlIEIgeyBzdHJ1Y3QgQyB7fTsgfQoKbmFtZXNwYWNlIEEgeyBpbnQgZihCOjpDIHgpIHsgcmV0dXJuIDE7IH0gfQoKaW50IGgoKSB7IHJldHVybiBBOjpnKEI6OkMoKSk7IH0KCmludCBtYWluKCkKewogICBzdGQ6OmNvdXQgPDwgaCgpOwp9
prog.cpp: In function 'int A::g(T) [with T = B::C]': prog.cpp:9:29: instantiated from here prog.cpp:3:68: error: cannot convert 'B::C' to 'int' for argument '1' to 'int A::f(int)'
-
result: Compilation error (maybe you wish to see an example for C++11)


