From 1961622106285535319
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7eaa8faac8da5016
X-Google-Attributes: gidf78e5,public
From: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Subject: Re: Defect Report: member == in container iterators considered harmful
Date: 1999/08/23
Message-ID: <37BD41BF.1447@wanadoo.fr>#1/1
X-Deja-AN: 516097118
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <7p4nj8$n3u@enews4.newsguy.com> <37B95B96.7F37@wanadoo.fr> <7pcoa8$2kf0@enews2.newsguy.com> <37BABF02.3EBE@wanadoo.fr> <7pf1b2$ls8@enews3.newsguy.com> <37BC0B5B.4AD8@wanadoo.fr> <7pi5ui$314r@enews3.newsguy.com>
X-Original-Date: Fri, 20 Aug 1999 13:53:35 +0200
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 935399830 26211 128.250.29.17 (23 Aug 1999 09:17:10 GMT)
Organization: Ecole normale superieure
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN8ERduEDnX0m9pzZAQGFXAF9EbxAXm7siFl2z18MSpJf46Vrtjw4AoNm t9pe6/TGPBh/EN+zmI7oMrUuEpfSer9M =GEPo
Mime-Version: 1.0
NNTP-Posting-Date: 23 Aug 1999 09:17:10 GMT
Newsgroups: comp.std.c++

Darin Adler wrote:
> 
> > Darin Adler wrote:
> >> I meant to propose a non-member function, which can be a friend if
> >> necessary. As I understand it, the friend function above *is* a non-member
> >> function.
> 
> Valentin Bonnard <Bonnard.V@wanadoo.fr> wrote:
> > Not really. It isn't a member, it isn't a normal global
> > function, it's something completely magical, a friend.
> 
> Before your messages in this thread, I had understood that "friend" was a
> relationship between a class and a function, rather than a special category
> of function. 

Actually, it's both.

> But you're saying here that a friend function is a special kind
> of function, not a non-member function which has been granted special
> privileges.

Again, it's both a non-member function with privileges and 
a special kind of function.

> I thought that a non-member function that was not a friend would work. But
> it now seems that a friend is required.

Correct

> It still seems to me that someone could make const_iterator be a non-nested
> class with a library-hidden name and just have the typedef inside the class.

Yes, why not.

> On the other hand, if only a friend function works, it still seems that my
> DR was correct. 

Hum, hum

[quotation: 
> However, the following code is not
> guaranteed to work:
> 
>     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. 
--end quotation]

> Here's what I'd like to know:
> 
>     Do you still think the DR solution I proposed is incorrect?

As you seem to imply in your DR that a non friend function 
solves the problem, yes. If all you wanted to say in your DR 
was that there is problem which should be solved the Right 
Way, then I have no objection against that.

>     If the standard is amended to require a non-member function, but the
> only kind of non-member function that will work is a friend, doesn't that
> mean that all implementers will have to use friend functions? Does the
> standard have to explicitly mention "friend" to be correct?

No, it doesn't has to do that. The standard doesn't even have to 
mention the notion of membership of overloaded operators.

>     Would a simple wording change make my DR solution correct, corresponding
> to the experiment I did on my copy of the library?

Remove all the references to membership ?

>     Will you help me correct the DR and resubmit it?

Yes

> I don't care so much if I made a mistake -- I'm willing to admit it if I
> did. But I do care whether the DR is wrong or right. I'd like the DR to have
> a good chance for fair consideration, unless there's a flaw in it. 

I am sure it will get fair consideration.

> I believe your original comment, saying that my suggested solution won't
> work, was passed on to the committee. 

Correct

> I think this will unnecessarily reduce
> the chance of the defect report being accepted. 

It will reduce the chance of the DR being accepted in 
an incorrect/misleading form. It won't kill the DR.

-- 

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



