Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 5th, 2006, 10:05 PM
Evan
Guest
 
Posts: n/a
Default Another "is this C++" question for the language lawyers

template <class CharT >
struct ctype_byname {
ctype_byname();
};


template < >
ctype_byname<char>::ctype_byname<char>();

This code compiles with GCC 3.4.4, Sun CC 5.8, and MSVC 7.1. It fails
to compile with GCC 4.1.1, Intel CC 9.1, and Comeau's online compiler.

So... who's got it right?

My hunch from the fact that GCC used to accept it and now doesn't, plus
the fact that Comeau rejects it, is that it's probably not legal, but
can anyone verify this?

I've got a copy of the standard, so feel free to cite it if you happen
to look there anyway, but I have no clue where to look really. (I read
through 14.7 but to no avail. I wonder if maybe there's something
relating to this with all the blah-ids in 14.7.2 para 2, but I don't
know the standard well enough to make that determination.)

Thanks,
Evan

  #2  
Old December 5th, 2006, 10:35 PM
Kai-Uwe Bux
Guest
 
Posts: n/a
Default Re: Another "is this C++" question for the language lawyers

Evan wrote:
Quote:
template <class CharT >
struct ctype_byname {
ctype_byname();
};
>
>
template < >
ctype_byname<char>::ctype_byname<char>();
>
This code compiles with GCC 3.4.4, Sun CC 5.8, and MSVC 7.1. It fails
to compile with GCC 4.1.1, Intel CC 9.1, and Comeau's online compiler.
>
So... who's got it right?
>
My hunch from the fact that GCC used to accept it and now doesn't, plus
the fact that Comeau rejects it, is that it's probably not legal, but
can anyone verify this?
The code is close to legal, but not quite: the constructor that you try to
specialize is not a member template. Thus, you need to lose the second
template parameter:

template <class CharT >
struct ctype_byname {
ctype_byname();
};

template < >
ctype_byname<char>::ctype_byname();



[snip]


Best

Kai-Uwe Bux
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles