Is T in this context deducible? 
July 23rd, 2005, 05:51 AM
| | | |
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 | 
July 23rd, 2005, 05:51 AM
| | | | 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 | 
July 23rd, 2005, 05:51 AM
| | | | 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 | 
July 23rd, 2005, 05:51 AM
| | | | 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 | 
July 23rd, 2005, 05:52 AM
| | | | 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 | 
July 23rd, 2005, 05:52 AM
| | | | 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). | 
July 23rd, 2005, 05:56 AM
| | | | 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 |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|