From -8027958791542002712
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7eaa8faac8da5016
X-Google-Attributes: gidf78e5,public
From: dHarrison@worldnet.att.net (Doug Harrison)
Subject: Re: Defect Report: member == in container iterators considered harmful
Date: 1999/08/18
Message-ID: <37ceebde.11431046@netnews.worldnet.att.net>#1/1
X-Deja-AN: 514108266
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7p4nj8$n3u@enews4.newsguy.com> <37B95B96.7F37@wanadoo.fr>
X-Original-Date: Tue, 17 Aug 1999 23:11:56 GMT
Content-Type: text/plain; charset=us-ascii
Organization: AT&T WorldNet Services
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN7pPyuEDnX0m9pzZAQFi/wF9GU0zu1fYeRZ0VnjRaCszlpj48OpR9fyK eoSaJVfj20M27CiJyMV841XFdLCeVLn8 =TgIk
Mime-Version: 1.0
Newsgroups: comp.std.c++

Valentin Bonnard wrote:

>>     bool check_equal(std::deque<int>::iterator i,
>>         std::deque<int>::const_iterator ci)
>>     {
>>         return i == ci;
>>     }
>> 
>> The reason for this is that there's no requirement that the == operator be
>> defined as a non-member function. 
>
>It's the contrary: as a non member function, deduction 
>won't ever work.

Who says std::deque::iterator has to be a member class? It could be defined
as std::__deque_iterator, and deque::iterator could just be a typedef for
it. It may not help you portably write a templated check_equal, but it
certainly helps the library implementer provide symmetric operator==.

>So mandating non member functions certainly:
>- isn't a solution

I think it's a solution for operator== et. al. Note that deque::iterator is
a random access iterator and thus has to support symmetric operator+ anyway.
This requires a non-member operator+ so you can say "n+i", where n is
difference_type and i is iterator.

>- goes agains the spirit of generic programming

Why?

-- 
Doug Harrison
dHarrison@worldnet.att.net
---
[ 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              ]



