public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Specialization of template class with inner template members
@ 2004-12-10 12:14 Boris Dorès
  2004-12-10 15:33 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Boris Dorès @ 2004-12-10 12:14 UTC (permalink / raw)
  To: gcc-help

   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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Specialization of template class with inner template members
  2004-12-10 12:14 Specialization of template class with inner template members Boris Dorès
@ 2004-12-10 15:33 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2004-12-10 15:33 UTC (permalink / raw)
  To: Boris Dorès; +Cc: gcc-help

Boris Dorès wrote:
>   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) :

The code is well formed. I don't know off hand if we have a bug report
about this -- submit one and we'll all find out.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-10 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-10 12:14 Specialization of template class with inner template members Boris Dorès
2004-12-10 15:33 ` Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).