This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: rel_ops issues
- To: Joe Buck <jbuck at racerx dot synopsys dot com>
- Subject: Re: rel_ops issues
- From: Gabriel Dos Reis <Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr>
- Date: 03 Apr 2001 23:13:51 +0200
- Cc: Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr (Gabriel Dos Reis), bkoz at redhat dot com (Benjamin Kosnik), Theodore dot Papadopoulo at sophia dot inria dot fr (Theodore Papadopoulo), libstdc++ at gcc dot gnu dot org
- Organization: CMLA, ENS Cachan -- CNRS UMR 8536 (France)
- References: <200104032027.NAA22079@racerx.synopsys.com>
Joe Buck <jbuck@racerx.synopsys.com> writes:
| > 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.
The key word is "if" -- an assumption the library is not funded to
make since the standard algorithm description requires only operator==.
[...]
| 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?
Since __normal_iterator is a class the library put in for its own
purposes, it should ensure it works properly without introducing
unwanted semantics in user programs. That pretty much exclude the
using-declaration and using-directive. In fact, the solution is to
overload operator!=, operator<, operator>, operator<= and operator>=
for __normal_iterator.
-- Gaby