I'm trying to understand why this program does not give an name-lookup ambiguity for i:
namespace X { int i = 1; }
namespace Q {
namespace P {
int i = 2;
using namespace X;
}
using namespace P;
int l = i;
}
int main() {}
If we modify it like this we get a name-lookup ambiguity:
namespace X { int i = 1; }
namespace P {
int i = 2;
using namespace X;
}
using namespace P;
int l = i;
int main() {}
The only change I made here is to remove the namespace Q and place it's content in the global namespace instead.
I have tried with 3 different compilers:
- GCC and Clang with http://melpon.org/wandbox
- visual c++ with http://webcompiler.cloudapp.net/
The all give the results stated in this email, and i'm trying to find out why.
Can anyone explain the behaviour in terms of the c++ standard? I fail to understand it.