Topic: name lookup and using directives


Author: user name <user182@MailAndNews.com>
Date: Sat, 28 Apr 2001 23:34:10 GMT
Raw View
I've tested on both gcc and comeau and both select f(char).

namespace N
  {
    void f (char) {}
  }

using namespace N;

int main ()
  {
    f(1);
  }

namespace N
  {
    void f (int) {}
  }

I know for a fact that if I replace "using namespace N"
with "using N::f", that the proper behavior is to select
f (char).

I know that because I found this

7.3.3 /9

  "The entity declared by a using-declaration shall be known in
   the context using it according to its definition at the point
   of the using-declaration. Definitions added to the namespace
   after the using-declaration are not considered when a use of
   the name is made."

But, I could not find equivalent language for the using directive case.

In fact what prompted this whole thing was when I came across

14.5.4 /7

This section describes that partial specializations are not found
by name lookup. It also describes as an example a modified template
version of the code I describe above, pointing out that
a using directive would foil name lookup in such cases.

So that made me scratch my head.  Is this something specific to
using declarations ?  Is my code fragment well formed ?

Thanks.

---
[ 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://www.research.att.com/~austern/csc/faq.html                ]