templated member function fails to compile when name duplicates existing template parameter

  • Thread starter Thread starter Trevor Morgan
  • Start date Start date
T

Trevor Morgan

I've been having problems when a templated member function has the same name
as ANY previously defined template parameter.

Here's the simplest case that demonstrates the problem.

This fails to compile under VC++ version 7.0

It has no problems under gcc.



//begin code
template <class T>
struct A
{};

struct B
{
template <typename TYPE>
void T()
{}
};

int main(int,char**)
{
B b;
b.T<int>();//error c2062: type 'int' unexpeced

return 0;
}
//end code
 
--------------------
From: (e-mail address removed) (Trevor Morgan)
Newsgroups: microsoft.public.dotnet.languages.vc
Subject: templated member function fails to compile when name duplicates existing template parameter
Date: 8 Aug 2003 07:41:10 -0700
I've been having problems when a templated member function has the same name
as ANY previously defined template parameter.

Here's the simplest case that demonstrates the problem.

This fails to compile under VC++ version 7.0

It has no problems under gcc.

Thanks for the report. This bug has been fixed in VS .Net 2003. I can see
how this would have been a frustrating one to track down; I suspect you've
already found a workaround :-).
 
Back
Top