Compile fails using valarray on 3.4.0 but not 3.3.2

Volker Reichelt reichelt@igpm.rwth-aachen.de
Tue Apr 27 18:42:00 GMT 2004


Hi Steven,

to make things short: GCC 3.4.0 is right, the code is wrong.
(GCC 3.4.0 is just more standard conformant than 3.3.2.)

In order to make the code compile you have to add something like

  template<class> class Slice_iter;
  template<class> class Cslice_iter;

  template<class T> bool operator==(const Slice_iter<T>& p, const Slice_iter<T>& q);
  template<class T> bool operator!=(const Slice_iter<T>& p, const Slice_iter<T>& q);
  template<class T> bool operator< (const Slice_iter<T>& p, const Slice_iter<T>& q);

  template<class T> bool operator==(const Cslice_iter<T>& p, const Cslice_iter<T>& q);
  template<class T> bool operator!=(const Cslice_iter<T>& p, const Cslice_iter<T>& q);
  template<class T> bool operator< (const Cslice_iter<T>& p, const Cslice_iter<T>& q);

before the definition of "Slice_iter". That's because of [14.5.3]/2 in
the standard. The friend declarations in Slice_iter require that a
declaration of the template function for "operator==" etc. is already there.

  template<class T> class Slice_iter {
  // ...
	  friend bool operator==<>(const Slice_iter& p, const Slice_iter& q);
	  friend bool operator!=<>(const Slice_iter& p, const Slice_iter& q);
	  friend bool operator< <>(const Slice_iter& p, const Slice_iter& q);
  };

See http://gcc.gnu.org/ml/gcc-bugs/2000-03/msg00605.html
for a similar problem (it misses the "<>", but the rest applies
to your problem) and the text from the standard.

Regards,
Volker




More information about the Gcc mailing list