This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Specialization of template class with inner template members


Hi everyone,

I hope the following issue hasn't been reported too many times...

  The following code used to compile fine with gcc 3.3 (linux x86), but
doesn't anymore with gcc 3.4 (just as a hint, it seems to compile fine
with Comeau) :

template<class T1,int N1>
class Class
{
public:
   template<class T2,int N2> T2 function( T2 param );
};

template<>
template<class T2,int N2>
T2 Class<int,1>::function( T2 param )
{ // line 11
        return param * N2;
}

int main()
{
        Class<int,1> instance;
        return instance.function<char,4>( 12 );
}

This produces the following output:

test-gcc34.cpp:11: error: template-id `function<>' for `T2 Class<int,
   1>::function(T2)' does not match any template declaration
test-gcc34.cpp:11: error: erreur de syntaxe before `{' token

It works if we add the specialized declaration of the class "Class":

template<>
class Class<int,1>
{
public:
   template<class T2,int N2> T2 function( T2 param );
};

but this can be painful if "Class" contains a lot more members.

It also works if "function" is only templated by one argument :

template<>
template<class T2>
T2 Class<int,1>::function( T2 param )
{ // line 11
        return param * 2;
}


Does anyone have a clue about what's going on ? Is this a bug or did we missed something ?

Thanks.

--
Boris Dorès
Buf Compagnie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]