I am trying to understand why this program does not give ambiguity to the name lookup 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 change it like this, we get the ambiguity of the search:
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 Q namespace and put its contents in the global namespace.
I tried with three different compilers:
All give the results indicated in this letter, and I'm trying to find out why.
Can someone explain the behavior in terms of the C ++ standard? I do not understand this.
source
share