Hi, I'm not sure if it is a bug, but I couldn't find a justification for this behaviour at http://www.open-std.org/jtc1/sc22/open/n2356/.
gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7) AMD Athlon(tm) XP 2600+, GNU/Linux (Red Hat Linux 8) To reproduce (`test.cpp' is attached): $ g++ test.cpp -o test gives (here) test.cpp: In function `int main()': test.cpp:61: no match for `templated_nested::A<int>::B& == templated_nested::A<int>::B&' operator Note that there are three similar constructs in `test.cpp' and operator lookup fails only in one of three cases: * templated class A with nested class B: lookup for operator== (A <type>::B, A <type>::B) FAILS * templated class A: lookup for operator== (A <type>, A <type>) SUCCEEDES * non-templated class A with nested class B: lookup for operator== (A::B, A::B) SUCCEEDES I believe all three should succeed or, stated in other words, I don't understand why the first one fails. Granted, I'm not exactly a guru of C++. Namespaces don't affect the behaviour. Member `operator==' is looked up perfectly. Paul
namespace templated_nested { template <typename type> struct A { struct B { }; }; template <typename type> inline bool operator== (typename A <type>::B, typename A <type>::B) { return true; } } namespace templated_non_nested { template <typename type> struct A { }; template <typename type> inline bool operator== (A <type>, A <type>) { return true; } } namespace non_templated_nested { struct A { struct B { }; }; inline bool operator== (A::B, A::B) { return true; } } int main () { { templated_nested::A <int>::B x; templated_nested::A <int>::B y; // Gives ``no match for `templated_nested::A<int>::B& == // templated_nested::A<int>::B&' operator''. x == y; } { templated_non_nested::A <int> x; templated_non_nested::A <int> y; // OK x == y; } { non_templated_nested::A::B x; non_templated_nested::A::B y; // OK x == y; } return 0; }