This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Template instatiation bug.
- To: Roy Dragseth <royd at math dot uit dot no>
- Subject: Re: Template instatiation bug.
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 30 Oct 1997 19:09:53 -0200
- Cc: egcs-bugs at cygnus dot com
- References: <199710301630.RAA26588@zapffe.mat-stat.uit.no>
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