From 386468910636700868
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7eaa8faac8da5016
X-Google-Attributes: gidf78e5,public
From: "Bill Wade" <bill.wade@stoner.com>
Subject: Re: Defect Report: member == in container iterators considered harmful
Date: 1999/08/18
Message-ID: <7pcj1q$105@library1.airnews.net>#1/1
X-Deja-AN: 514091187
X-NNTP-Posting-Host: !X&ZP1k-X(+_/1- (Encoded at Airnews!)
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <7p4nj8$n3u@enews4.newsguy.com>
X-UID: 0000000001
X-Status: $$$T
X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: Neosoft (using Airnews.net!)
Abuse-Reports-To: abuse at airmail.net to report improper postings
Newsgroups: comp.std.c++
Originator: clamage@taumet



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 '-'.



[ 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              ]




