ISO/ IEC JTC1/SC22/WG21 N0745

																	#X3J16-95-145R1, #WG21-745R1
 
	Bjarne Stroustrup:
 
	Relaxation of Qualified Lookup
 
 
 
Motion to relax explicit qualification rules for namespaces:
 
Replace the second and third sentence of paragraph 3 of section 7.3.1.1
[namespace.qual] with
 
The search for a name after a :: locates named members of a namespace or class
as follows: Given X::m, if m is declared in X, X::m refers to the entity or
entities named m in X .Otherwise, if X has using-directives for namespaces or
classes N1..Nn, X::m refers to the entity or entities named N1::m..Nn::m.
If the set of entities found is empty, the program is ill-formed. If that set
has exactly one member, X::m refers to that member. Otherweise, if that set
has more than one member, the program is well formed if the use of the name
is one that allows a unique member to be chosen, such as overload resolution
(13.2 [over.match]) or resolution between class names and non-class names
(9.1 [class.name]). Otherwise, the program is ill-formed.
 
[example
 
	int x;
 
	namespace A {
		void f(int);
		void g(int);
		int i;
	}
 
	namespace B {
		void f(char);
		int i;
	}
 
	namespace AB {
		using namespace A;
		using namespace B;
		void g();
	}
 
	void h()
	{
		AB::g();     // calls the g() declared in AB
		AB::f(1);    // calls A::f(int)
		AB::f('c');   // calls B::f(char)
		AB::x++;  // error: no x in AB
		AB::i++;   // error: ambiguous, A::i and B::i
	}
 
--end example]
 
An entity found more than once in a qualified name lookup does not constitute
an ambiguity.
 
[example:
 
	namespace A {
		int a;
	}
 
	namespace B {
		using namespace A;
	}
 
	namespace C {
		using namespace A;
	}
 
	namespace BC {
		using namespace B;	
		using namespace C;
	}
 
	void f()
	{
		BC::a++;   // ok
	}
 
	namspace D {
		using A::a;
	}
 
	namespace BD {
		using namespace B;
		using namespace D;
	}
 
	void g()
	{
		BD::a++;    // ok
	}
 
--example]
 
No namespace is considered more than once in the lookup of a member.
 
[example
 
	namespace B {
		int b;
	}
 
	namespace A {
		using namespace B;
		int a;
	}
 
	namespace B {
		using namespace A;
	}
 
	void f()
	{
		A::a++;    // ok
		B::a++;    // ok
		A::b++;    // ok
		B::b++;    // ok
	}
--end example]