Specialization of template class with inner template members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux