This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Compile fails using valarray on 3.4.0 but not 3.3.2
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: hattons at globalsymmetry dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 27 Apr 2004 19:22:39 +0200 (CEST)
- Subject: Re: Compile fails using valarray on 3.4.0 but not 3.3.2
- Reply-to: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
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