"Siegfried" <[EMAIL PROTECTED]> writes: > Anyway, can anyone speculate with (for) me as to why the compiler > (and c++ specification) works this way? It does not seem logical to > only search the std namespace. It seems that writing application > specific code for the std namespace should be forbidden.
[The question is: why does name lookup stop once the name is found in a scope, even if this occurence doesn't fit.] Consider this situation: #include <iostream> namespace myNamespace { struct myStruct {} void f(myStruct const &) {} } int main() { myNamespace::myStruct s; f(s); } Argument-dependant lookup says that f is first looked up in namespace myNamespace; if the name f isn't found in namespace myNamespace, it is looked up in the global namespace. This causes myNamespace::f to be found an invoked, as everybody would expect. Now what should we expect if somebody adds void f(myStruct &) {} in the global namespace, possibly in some remote header that is indirectly #included. It would be very surprising if ::f would suddenly be called. That's why name lookup stops at the first scope where the name is found. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus