I have two strange cases where it seems that the code should compile, but it is not. To get started, consider the code below that compiles successfully:
struct A { template <class T> void member_func(T t) { global_func(t); } }; int main() { }
But if I fully qualify global_func by prefixing with "::", it does not compile with the error "global_func" has not been declared in this area ":
struct A { template <class T> void member_func(T t) { ::global_func(t); } }; int main() { }
Also, if I try to pass global_func to boost :: bind, it does not compile (same error):
#include <boost/bind.hpp> class A { template <class T> void member_func(T t) { boost::bind(global_func)(t); } }; int main() { }
Why doesn't it compile in these cases? It seems that the member_func () template method is not created, so it should not detect the missing function error.
source share