Instantiating a static data member of a class template
Gabriel Dos Reis
gdr@integrable-solutions.net
Fri May 23 08:40:00 GMT 2003
Matt Austern <austern@apple.com> writes:
| gcc 3.3 accepts this code, and mainline rejects it:
| template <class C>
| class A {
| static int i;
| };
|
| int A<int>::i = 1;
|
| Looking through clause 14 of the C++ standard, I believe that mainline
| is right and 3.3 is wrong. I may be confused, but it looks to me as
| if the definition of A<int>::i isn't legal: I don't think it satisfies
| the definition of an implicit instantiation, an explicit
| instantiation, an explicit specialization, or anything else.
|
| Do other people agree that mainline's behavior is correct?
I agree with you and mainline. The above definition could be valid
only if it were an explicit specialization, i.e. preceeded with the
empty template-header "template<>".
-- Gaby
More information about the Gcc
mailing list