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

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
 
A

Arjun Bijanki [VCPP MSFT]

--------------------
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 :).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top