Another "is this C++" question for the language lawyers

E

Evan

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
 
K

Kai-Uwe Bux

Evan said:
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
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top