I have the following set of classes (a minimal replication of my real situation):
namespace Parent
{
class A {};
namespace Nested
{
class A {};
}
template <typename T>
class B
{
A myA;
};
}
I would expect that the member Parent::B::myA
should be unambiguously resolved to be of type Parent::A
. However, elsewhere in my project I have this:
namespace Parent
{
using namespace Nested;
void foo()
{
B<int> myB;
}
}
which fails to compile under MSVC 2003:
error C2872: 'A' : ambiguous symbol
could be 'Test.cpp(5) : Parent::A'
or 'Test.cpp(9) : Parent::Nested::A'
Test.cpp(26) : see reference to class template instantiation 'Parent::B<T>' being compiled
with [ T=int ]
The code will compile if I am explicit in my declaration of B::myA
, i.e. Parent::A myA;
. However, the code compiles as it is under gcc-4.3.4. Is this simply a bug with MSVC 2003, or should I really have to worry about the scope in which my templates may be instantiated?