From -8664811534249043453
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7eaa8faac8da5016
X-Google-Attributes: gidf78e5,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: Defect Report: member == in container iterators considered harmful
Date: 1999/08/19
Message-ID: <37BBD5DB.F6973D6A@physik.tu-muenchen.de>#1/1
X-Deja-AN: 514751374
X-Nntp-Posting-Host: coulomb.t30.physik.tu-muenchen.de
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7p4nj8$n3u@enews4.newsguy.com> <7pcj1q$105@library1.airnews.net>
X-Accept-Language: German/Germany, de-DE, German, de, en
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset=us-ascii
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Mime-Version: 1.0
Newsgroups: comp.std.c++
Originator: clamage@taumet


Bill Wade wrote:
> 
> Darin Adler wrote in message <7p4nj8$n3u@enews4.newsguy.com>...
> >Proposed resolution:
> >
> >Add the following text to section 23.1 [lib.container.requirements]:
> >
> >The iterator and const_iterator types defined by a standard container may
> be
> >classes. If they are, any ==, !=, >, <, >=, or <= operator functions
> defined
> >for these classes to satisfy iterator requirements must be defined in the
> >std namespace, not as member functions.
> >
> >(Perhaps someone on the library committee can word it better. This is the
> >best I could do.)
> 
> I'm not on the committee, but I believe the above is overly restrictive.
> Here are two ways that member functions can support the desired test ( i ==
> ci;    // iterator i;  const_iterator ci).
> 
> 1) bool iterator::operator==(const_iterator) const;
> 2) class iterator: public const_iterator { ... };    // inherit operator==()
> 
> Also note that binary minus should be added to the list of operators.  I
> believe that all iterators which support '<' also support '-'.

So perhaps instead sth. like the following should be added to the
standard:

 If i1 and i2 are iterators, then if any expression on one
 side of the following table is allowed, the operation on
 the other side shall be allowed, too, and have the same
 result:

 i1 == i2  |  i2 == i1
 i1 != i2  |  i2 != i1
 i1 > i2   |  i2 < i1
 i1 >= i2  |  i2 <= i1

I don't think this does constrain the implementation too
much, and it has exactly the intended effect.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




