Template instatiation bug.
Alexandre Oliva
oliva@dcc.unicamp.br
Thu Oct 30 13:15:00 GMT 1997
Roy Dragseth writes:
> Hi, I just discovered what I beleive is a bug in egcs-971023.
It is not a bug, this is correct behavior.
First, you must declare operator>> as a template:
template <class T> class C_matrix;
template <class T> istream& operator>>(istream &s, C_matrix<T> &A);
> template<class T>
> class C_matrix
> {
Now you can declare operator>> as a friend, but you must tell the
compiler it is a template function using angle brackets:
> friend istream& operator>> <> (istream &s, C_matrix &A);
^^ note the template notation here
> };
Now, your program should work.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc-bugs
mailing list