This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Specialization of template class with inner template members
- From: Boris Dorès <boris at buf dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 10 Dec 2004 13:14:26 +0100
- Subject: Specialization of template class with inner template members
- Reply-to: Boris Dorès <boris at buf dot com>
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