1

A few weeks ago I wrote a trait class for 2d entities like this:

template<typename T>
struct traits_2d
{
    typedef T coordinates_type;
    typedef vector_2d<T> position_type;
    typedef vector_2d<T> direction_type;
    typedef vector_2d<T> size_type;
};

The trait class was used as follows:

template<typename T>
struct aabb_2d : public traits_2d<T>
{
    position_type origin;
    size_type size;
};

The Standard says that template dependent names must be fully qualified, so this should not compile. Of course GCC compilation fails and says something like:

Expected nested-name specifier. Could be 'typename traits_2d<T>::position_type'.

But, on the other hand, I was using this pattern for two weeks in MSVC11 (Visual Studio 2012) and it works and compiles fine.

Why seems like MSVC11 does not follow this language rule?

NOTE: This question is not a duplicate of Propagating 'typedef' from based to derived class for 'template' or its duplicates, it asks about why something that should be an error works in MSVC.

Community
  • 1
  • 1
Manu343726
  • 13,969
  • 4
  • 40
  • 75
  • 2
    Multiple duplicates... VS does not correctly implement two phase lookup, and does not require the use of `typename` there. That is an *extension* (to give it a name) that will be fixed somewhere in the future – David Rodríguez - dribeas Nov 12 '13 at 21:30
  • @DavidRodríguez-dribeas thanks a lot. So, as I thought before, MSVC sucks. If you post that as an answer I would accept it. – Manu343726 Nov 12 '13 at 21:37

0 Answers0