Topic: Using-directive and name lookup


Author: Hideaki Onaru <gomarine@mx1.ttcn.ne.jp>
Date: 2000/03/17
Raw View
3.4.1 Unqualified name look up, paragraph 2:

"The declarations from the namespace nominated by a using-directive become
visible in a namespace enclosing the using-directive; see 7.3.4. For the
purpose of the unqualified name look up rules described in this subclause, the
declarations from the namespace nominated by the using-directive are
considered members of that enclosing namespace."

7.3.4 Using directive, paragraph 2:

"A using-directive specifies that the names in the nominated namespace can be
used in the scope in which the using-directive appears after the
using-directive. During unqualified name look up (3.4.1), the names appear as
if they were declared in the nearest enclosing namespace which contains both
the using-directive and the nominated namespace. [Note: in this context,
_(IR_(Bcontains_(IS_(B means _(IR_(Bcontains directly or indirectly_(IS_(B. ] A using-directive does
not add any members to the declarative region in which it appears."

These two paragraphs seem inconsistent for me.
For example,

namespace A {
    int i;
}
namespace B {
    using namespace A;
    int i;
    void f() {
        i = 10;
    }
}

According to 7.3.4, i in f() refers to B::i, which hides A::i.
On the other hand, according to 3.4.1, i in f() is ambiguous between A::i and
B::i.

Thank you.


Hideaki Onaru

---
[ 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              ]