This is the mail archive of the gcc-bugs@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]

Template bug


Hey,

  I was attempting to make a template class and wanted to overload the <<
operator.  In the class declaration, I had

template<class T>
class list{
  ...
  friend ostream& operator<< <T>(ostream&,list<T>&);
  ...
};

If I declared the operator<< line as

friend ostream& operator<< (ostream&,list<T>&);

the compiler gave a warning that I must have <> after the funtion name.  I
took this to mean that I needed to put <T> so that it would be treated as
a template instantiation, so I changed it to

friend ostream& operator<< <T>(ostream&,list<T>&);

In the declaration part of the code, I had

template<class T> ostream& operator<<(ostream& s,list<T>& l){
...
}

In this case, when I compiled I got an error that there was no match for
`_IO_ostream_withassign & << list<int> &' (I used list<int> for my
instantiation).  Anyway, I realized that I had left out the <T> after the
function name, so I changed it to

template<class T> ostream& operator<< <T>(ostream& s,list<T>& l){
...
}

When I tried to compile this, I got

list.C:163: Internal compiler error.
list.C:163: Please submit a full bug report to `egcs-bugs@cygnus.com'.

So that's what I'm doing.

Thanks,
Rich




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