When I compile the following snippet with g++
template<class T>
class A
{};
template<class T>
class B
{
public:
typedef A<T> A;
};
the compiler tells me
error: declaration of ‘typedef class A<T> B<T>::A’
error: changes meaning of ‘A’ from ‘class A<T>’
On the other hand, if I change the typedef
to
typedef ::A<T> A;
everything compiles fine with g++
. Clang++ 3.1 doesn't care either way.
Why is this happening? And is the second behavior standard?
See Question&Answers more detail:os