This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

Re: rel_ops issues



> Right.  But they don't perform identically on X<int>.  Which is the whole
> purpose of the exercise.  

But if operator!= returns the same value as operator!(operator==), then
the only difference is any side effects, like printing messages.  But no
matter.  You have your reasons (good ones) to worry about rel_ops; I have
my reasons (also good ones, and standard conformance requires it) to want
to support programs that use it.  I think that the way to accomodate both
is to avoid use of the rel_ops in the standard library, but take measures
to make sure that it works for users who want it.

> | However, for the sake of harmony I will accept either alternative above
> | as a fix for std::equal.
> 
> It is needless to that I dissmiss #1 and favor fix #2.

Fine.  There is an agreed solution to c++/2406. I have sent a patch,
see http://gcc.gnu.org/ml/gcc-patches/2001-04/msg00163.html .

This leaves the other issue (2405): additional operator!= (etc) definitions
for __normal_iterator to allow __normal_iterator and rel_ops to coexist.
My proposed fix is to add definitions like

template<typename _Iterator, typename _Container>
inline bool
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
	   const __normal_iterator<_Iterator, _Container>& __rhs)
{ return !(__lhs == __rhs); }

and similarly for >, >=, <= to stl_iterator.h.  This is needed so
that vector<T> works in a compilation unit that has said

using std::rel_ops::operator=;

or

using namespace std::rel_ops;

Without it there is a conflict between the two operator!= definitions.
This third definition will be preferred to either of the other two
for != on two vector iterators.

Objections?




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