problem with template disambiguation with MSVS2005

The following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <vector>
#include <string>
using namespace std;

template<typename T>
class A
{
public:
   string getType() const
   {
      return "A";
   }
protected:
   T mValue;
};

template<typename T>
class B : public A<vector<T> >
{
public:
   bool operator==(const B &rhs) const
   {
      if(getType() == rhs.getType())         // LINE A
      {
         return mValue == rhs.mValue;        // LINE B
      }
      return false;
   }
};

int main()
{
   B<int> foo;
   B<int> bar;
   return foo == bar;
}


will not compile on with a recent (4.x) gcc due to lack of disambiguation on lines A and B. Changing them to
1
2
      if(this->template getType() == rhs.getType())
         return this->template mValue == rhs.mValue;


fixes the problem on gcc. However, Microsoft Visual Studio 2005 (unmanaged C++) complains:

error C2059: syntax error : 'template'
...


Does the MS compiler not allow this use of template? I'd like to avoid converting the this->template to a macro and #defining to do the correct thing on the different platforms but I don't see another way.
Topic archived. No new replies allowed.