friend function in template class declaration

Toshinao Ishii ici@qua.crl.melco.co.jp
Fri Oct 1 00:00:00 GMT 1999


Hi.

The following code was compiled in gcc-2.8.1 but not in gcc-2.95.1.

  template <class T> class Array
  {
     // necessary declarations here

     friend ostream& operator << <>( ostream &os, const Array<T>& arr );
  };

The compilation error occurs with messages something like

  invalid use of declaration of `class Array<int>'
  forward declaration of `class Array<int>'
  confused by earlier errors, bailing out


The following similar code is compled without error.

  template <class T> class Array
  {
     // necessary declarations here
  };
  template <class U> ostream& operator << ( ostream &os, const Array<U>& arr );


Please let me know whether (and how) friend function declaration in template
class is changed.

Thanks in advance.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$B@P0f=SD>(B   Toshinao Ishii

   Advanced Technology R&D Center (ATC)   $B;0I)EE5!!J3t!K(B
   Mitsubishi Electric Corporation        $B@hC


More information about the Gcc-help mailing list