This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Compile fails using valarray on 3.4.0 but not 3.3.2


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



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