c++/3028: 3.0 Compiler complains about template that used to work under 2.95
Artem Khodush
artem@duma.gov.ru
Fri Jun 1 08:09:00 GMT 2001
>
> template<class ALLOC> class IListBase
> {
> protected:
> struct IListNode
> {
> IListNode *next;
> int datum;
> };
>
> class IListNode *head;
> class IListNode *tail;
>
> int find(int datum);
> };
>
> template<class ALLOC> int IListBase<ALLOC>::find(int d)
> {
> IListNode<ALLOC> *node;
> for(node = head; node != 0; node = node->next)
> {
> if(node->datum == d)
> {
> return 1;
> }
> }
> return 0;
> }
>
>
> >Fix:
> A workaround seems to be to move the inner node class
> out of the template list class and make it its own template
> (but that breaks the protection).
Well, the code works if <ALLOC> after the IListNode is omitted.
I believe gcc 3.0 is right, IListNode is indeed not a template.
More information about the Gcc-bugs
mailing list