I tried to consult the standard on the resolution of do_run, and found "For the part of the lookup using unqualified name lookup (3.4.1) or qualified name lookup (3.4.3), only function declarations from the template definition context are found". What exactly is the context?
In the following example, do_run(int) somehow "hides" do_run(domain::mystruct), and the compiler complains that o can't be converted to int. If I comment out do_run(int), do_run(domain::mystruct) becomes visible to run, and the code is compiled. Is this behavior related to the "context" referred to in the standard? Seems to me both do_run(int) and do_run(domain::mystruct) should be visible to (resolvable) run.
namespace domain {
struct mystruct { };
}
void do_run(domain::mystruct) { cout << "do_run(domain::mystruct)" << endl; }
namespace lib { namespace details {
template <class T>
class runner {
public:
void run(T t) { do_run(t); }
};
void do_run(int) { cout << "do_run(int)" << endl; }
}}
int main() {
domain::mystruct o;
lib::details::runner<domain::mystruct> r;
r.run(o);
return 0;
}
In the presence of do_run(int), I need an extra step to bring do_run(domain::mystruct) into the "context". there're three ways:
- put
do_run(domain::mystruct)in namespace domain. - put
do_run(domain::mystruct)in namespace lib::details. - add
using ::do_runinside namespace lib::details.
So I deduced the context is namespace lib::details and namespace domain?
Compiler VS2010