Afficher un message
Vieux 07/02/2008, 19h47   #6
Andrey Tarasevich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problems with template arguments using G++ compiler

pce@ecosimpro.com wrote:
> ...
> Do you mean that it is a known problem in GNU Compiler?
> ...


It is not. It is a problem with your code. What you are trying to do is
called "explicit specialization". (In this case you are trying to
perform explicit specialization of a static member of class template).
The syntax for explicit specialization always begins with 'template<>'
(note the empty '<>').

Your original code made no sense. I don't know why it compiled in MSVC
and partially compiler in GNU.

When the compiler saw the 'template<int> ...' part it assumed that you
are trying to define a completely different, new, unrelated template
with an unnamed template parameter of 'int' type. It was probably
supposed to choke on the rest of the "definition", but for some reason
did not.

When the compiler saw the 'template<foo> ...' part it, once again,
assumed that you are trying to define another completely different, new,
unrelated template with an unnamed template parameter of 'foo' type.
Since it is illegal to use class types as non-type template parameters,
GNU immediately complained. I don't know why MSVC didn't.

--
Best regards,
Andrey Tarasevich
  Réponse avec citation
 
Page generated in 0,04608 seconds with 9 queries