Topic: Name hiding with using-directives in _un_qualified lookup.


Author: asbinn@rstcorp.com
Date: 1998/06/10
Raw View
3.4.3.2 paragraph 5 of the FDIS reads, with the example:

5 During the lookup of a qualified namespace member name, if the
lookup finds more than one declaration of the member, and if one
declaration introduces a class name or enumeration name and the other
declarations either introduce the same object, the same enumerator or
a set of functions, the non-type name hides the class or enumeration
name if and only if the declarations are from the same namespace;
otherwise (the declarations are from different namespaces), the
program is ill-formed.

[Example:

namespace A {
  struct x { };
  int x;
  int y;
}
namespace B {
  struct y { };
}
namespace C {
  using namespace A;
  using namespace B;
  int i = C::x; // OK, A::x (of type int)
  int j = C::y; // ambiguous, A::y or B::y
}
end example]

My question is: What about _un_qualified name lookup.  Imagine if the
last few lines read:

  int i = x;
  int j = y;

I assume that the use of 'x' would still be ok, but the use of 'y'
would be an error because the A::y variable would hide the B::y
structure.

I re-read 3.3.7 [basic.scope.hiding] paragraph 2, which implies that
the normal name-hiding rules apply the above situation.  Paragraph 4
of the same section mentions _qualified_ name lookup.

Paragraph 2 of 3.4.1 [basic.lookup.unqual] seems to indicate that the
normal name hiding-rules apply to the above situation.

I found it odd that the sections on using-declarations give explicit
statements regarding name hiding, and using-directives with
_qualified_ name-lookup gives explicit rules for name hiding; but no
explicit mention of name hiding when using-directives are used with
_un_qualified name lookup.

Am I missing something?  Is my above conclusion correct?


Aaron


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]