Afficher un message
Vieux 07/02/2008, 13h39   #1
pce@ecosimpro.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problems with template arguments using G++ compiler

Hello,

we are having problems when trying to compile a template code using
GNU G++ compiler, however it compiles properly using Microsoft C++
compiler.

Given the following declaration

class foo
{
};

template< class T >
class myclass {
public:
static myclass *s_centl;
};

myclass<int> obj1; // OK in MS C++ and GNU
myclass<foo> obj2; // OK in MS C++ and GNU

template<int> myclass<int>* myclass<int>::s_centl = new
myclass<int>() ; // OK in MS C++ and GNU

template<foo> myclass<foo>* myclass<foo>::s_centl = new
myclass<foo>() ;// OK in MS C++ but fails in GNU

the last statement produces the following error when using GNU C++
compiler:
"error 'class foo" is not a valid type for a template constant
parameter"

what I have to do to define properly this static member in GNU ?

Many thanks in advance
Pedro

pce1962
  Réponse avec citation
 
Page generated in 0,05233 seconds with 9 queries