Topic: Does the standard require friend operator== rather than member operator==


Author: "Darin Adler" <darin@bentspoon.com>
Date: 1999/08/02
Raw View
John Potter wrote:

> The standard also does not require C::const_iterator == C::iterator to be
> usable either.

The standard might require that implicitly. Table 65 says that X::iterator
for any container type must be convertible to X::const_iterator. Combine
that with the equality-comparable requirement, and I can't imagine a
conforming implementation where C::const_iterator == C::iterator wouldn't
work.

> I agree that it should be usable in both directions.

Great! So now we're trying to figure out the best way to get this into the
Defect Report process.

> Next, where to put it?  It would seem to belong in the iterators (24)
> but there is no mention of the names iterator and const_iterator there.
> That leaves containers (23) and likely other places where the two
> terms are defined like string (21) and maybe streams.  Could it be put
> in introduction (17)?

I think perhaps something in the introduction that says that non-member
functions should be used for class-defined binary operators for any classes
defined by the library. I don't think that this would unduly constrain
people who were implementing the library, and I hope it qualifies as a
defect.

So does anyone besides John or me have any thoughts about this? Maybe I
should just write it up and move on.

    -- Darin


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