Is T in this context deducible?

V

Victor Bazarov

Here is the code:
-------------------------
class Foo
{
public:
template<class T> T* foo()
{
return 0;
}
};

int main()
{
char* (Foo::*pFooMember)() = &Foo::foo; // OK?
}
 
K

Kristo

Victor said:
Here is the code:
-------------------------
class Foo
{
public:
template<class T> T* foo()
{
return 0;
}
};

int main()
{
char* (Foo::*pFooMember)() = &Foo::foo; // OK?
}

G++ 3.4.2 warned about unused pFooMember but that's it. Looks OK to
me.

Kristo
 
A

Alan Johnson

Victor said:
Here is the code:
-------------------------
class Foo
{
public:
template<class T> T* foo()
{
return 0;
}
};

int main()
{
char* (Foo::*pFooMember)() = &Foo::foo; // OK?
}
--------------------------
Is it well-formed? I thought so, and Comeau agreed. How
do other compilers behave? I know that VC++ 2005 fails.

V

$ CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 2001/05/15
$ CC test.cpp
"test.cpp", line 12: Error: Could not find a match for Foo::foo<Foo::T>().
1 Error(s) detected.

Visual Studio.NET appears to have no problem with it, however.

-Alan
 
C

Chris Theis

Alan Johnson said:
$ CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 2001/05/15
$ CC test.cpp
"test.cpp", line 12: Error: Could not find a match for Foo::foo<Foo::T>().
1 Error(s) detected.

Sun's workshop 5.3 is already quite dated, so I'm not too surprised that it
has problems with this rather tricky thing.
Visual Studio.NET appears to have no problem with it, however.

Which version are you refering to. My VS.NET 7.1 (compiler build 13.10.3077)
chokes on it, although IMHO Victor's program is well-formed. However, I
recall that the same problem appeared already about three years ago and the
MS compiler still seems incapable of handling this, which might be due to
their deduction mechanism.

Probably Daveed or another in-depth-template guru could shed some light on
this?

Cheers
Chris
 
V

Victor Bazarov

Alan said:
$ CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 2001/05/15
$ CC test.cpp
"test.cpp", line 12: Error: Could not find a match for Foo::foo<Foo::T>().
1 Error(s) detected.

Visual Studio.NET appears to have no problem with it, however.

Really? Yesterday I submitted this as a bug in VC++ v8 (2005) and they
acknowledged it and postponed it essentially immediately. If you care,
the bug ID is FDBK28043. I also checked with .NET 2003, same problem.

V
 
A

Alan Johnson

Victor said:
Really? Yesterday I submitted this as a bug in VC++ v8 (2005) and they
acknowledged it and postponed it essentially immediately. If you care,
the bug ID is FDBK28043. I also checked with .NET 2003, same problem.

V

I just retested to make sure, and it compiled it again just fine. This
is version 7.0 (VS.NET 2002).
 
V

Victor Bazarov

Alan said:
Victor said:
Alan said:
Victor Bazarov wrote:
[...]

Visual Studio.NET appears to have no problem with it, however.



Really? Yesterday I submitted this as a bug in VC++ v8 (2005) and they
acknowledged it and postponed it essentially immediately. If you care,
the bug ID is FDBK28043. I also checked with .NET 2003, same problem.

V


I just retested to make sure, and it compiled it again just fine. This
is version 7.0 (VS.NET 2002).

Thank you for checking again. Microsoft must have broken this one in 7.1
while fixing numerous other things. Well, good to know it's not just me
who breaks things while fixing bugs and introducing new features :)

V
 

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

Members online

Forum statistics

Threads
474,204
Messages
2,571,066
Members
47,672
Latest member
svaraho

Latest Threads

Top