From -4041244170519849881
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bc82bd0900b8b4ac
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2000-12-20 08:18:04 PST
Path: supernews.google.com!sn-xit-02!supernews.com!news-x.support.nl!colt.net!dispose.news.demon.net!demon!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: remove.haberg@matematik.su.se (Hans Aberg)
Newsgroups: comp.std.c++
Subject: Re: Feature Request: Fast "find" for sorted random access containers
Date: Wed, 20 Dec 2000 16:16:40 GMT
Organization: Mathematics
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <remove.haberg-2012000045090001@du129-226.ppp.su-anst.tninet.se>
References: <remove.haberg-1712001452460001@du131-226.ppp.su-anst.tninet.se> <gums3t4chvsdcuaipte3atg51f5l16cvn2@4ax.com> <remove.haberg-1812002251330001@du134-226.ppp.su-anst.tninet.se> <3A3F63A6.527B4E5D@wizard.net>
X-Trace: mail2news.demon.co.uk 977329021 mail2news:29529 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
NNTP-Posting-Date: 19 Dec 2000 23:45:10 GMT
Lines: 43
Xref: supernews.google.com comp.std.c++:3043

In article <3A3F63A6.527B4E5D@wizard.net>, James Kuyper
<kuyper@wizard.net> wrote:
>> For some reason, one has not bothered implementing +, - on containers such
>> as list and their iterators with respect to the iterator difference_type;
>
>That was quite deliberate. Operator overloads, by their very nature,
>have a tendency to get used inadvertently. It was decided to implement
>those operators only on the containers where they have inexpensive
>implementations.

Well, I think that classes such as vector and list could have the same
interface in this respect.

> If you try to use an algorithm that requires +/-
>difference_type on a non-reversible container, you'll get a diagnostic
>message that will warn you that the algorithm may be significantly more
>expensive than you thought (unless of course the algorithm already has
>different specializations for forward and bi-directional iterators, such
>as for example, std::advance<>()).

I have not seen this; please give an example when this diagnostic message
is issued.

-- In general, it is better to strive for a simple, common interface, and
allow such diagnostic messages be issued to those that want it, rather
than that one should have to revert to specialty programming when the
features are needed. -- The idea with name overloading is to cut down on
the things that the programmer need to remembers, so it must be better to
have those operators available, rather than the writers of the library
trying to police its uses.

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

---
[ 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://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]



