Connecting Tech Pros Worldwide Help | Site Map

Is T in this context deducible?

  #1  
Old July 23rd, 2005, 05:51 AM
Victor Bazarov
Guest
 
Posts: n/a
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
  #2  
Old July 23rd, 2005, 05:51 AM
Kristo
Guest
 
Posts: n/a

re: Is T in this context deducible?


Victor Bazarov wrote:[color=blue]
> 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.[/color]

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

Kristo

  #3  
Old July 23rd, 2005, 05:51 AM
Alan Johnson
Guest
 
Posts: n/a

re: Is T in this context deducible?


Victor Bazarov wrote:[color=blue]
> 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[/color]

$ 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
  #4  
Old July 23rd, 2005, 05:51 AM
Chris Theis
Guest
 
Posts: n/a

re: Is T in this context deducible?



"Alan Johnson" <alan@undisclosed.com> wrote in message
news:d768ag$5ck$1@news.Stanford.EDU...[color=blue]
> Victor Bazarov wrote:[color=green]
>> 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[/color]
>
> $ 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.[/color]

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

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


  #5  
Old July 23rd, 2005, 05:52 AM
Victor Bazarov
Guest
 
Posts: n/a

re: Is T in this context deducible?


Alan Johnson wrote:[color=blue]
> Victor Bazarov wrote:
>[color=green]
>> 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[/color]
>
>
> $ 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.[/color]

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
  #6  
Old July 23rd, 2005, 05:52 AM
Alan Johnson
Guest
 
Posts: n/a

re: Is T in this context deducible?


Victor Bazarov wrote:[color=blue]
> Alan Johnson wrote:
>[color=green]
>> Victor Bazarov wrote:
>>[color=darkred]
>>> 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[/color]
>>
>>
>>
>> $ 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.[/color]
>
>
> 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[/color]

I just retested to make sure, and it compiled it again just fine. This
is version 7.0 (VS.NET 2002).
  #7  
Old July 23rd, 2005, 05:56 AM
Victor Bazarov
Guest
 
Posts: n/a

re: Is T in this context deducible?


Alan Johnson wrote:[color=blue]
> Victor Bazarov wrote:
>[color=green]
>> Alan Johnson wrote:
>>[color=darkred]
>>> Victor Bazarov wrote:
>>>> [...]
>>>
>>> Visual Studio.NET appears to have no problem with it, however.[/color]
>>
>>
>>
>> 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[/color]
>
>
> I just retested to make sure, and it compiled it again just fine. This
> is version 7.0 (VS.NET 2002).[/color]

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
stream operator of a class nested in a class template Ares Lagae answers 4 October 20th, 2008 08:05 PM
why is operator<< not found homsan toft answers 4 May 31st, 2006 04:55 PM
Operator<<, in nested templated classes. Eddie Parker answers 1 September 9th, 2005 07:05 PM
Cannot invoke a templated ctor Momchil Velikov answers 10 July 19th, 2005 07:22 PM