From -3343678380453235059
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,8d7ae4b2a3e77f8b
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-08-12 11:43:27 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: nesotto@cs.auc.dk ("Thorsten Ottosen")
Newsgroups: comp.std.c++
Subject: Re: Why is there no range type in the standard library?
Date: Tue, 12 Aug 2003 18:43:26 +0000 (UTC)
Lines: 55
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3f37a6be$0$14560$afc38c87@news.optusnet.com.au>
References: <95e0e5ef.0308060330.28aefaae@posting.google.com>
X-Trace: mail2news.demon.co.uk 1060713806 6210 10.0.0.1 (12 Aug 2003 18:43:26 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 12 Aug 2003 18:43:26 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 19me7B-0001c1-00
	for mail2news@news.news.demon.net; Tue, 12 Aug 2003 18:43:25 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id EAA27519; Wed, 13 Aug 2003 04:43:22 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Spam-Status: No, hits=-5.4 required=5.0
	tests=BAYES_01,PRIORITY_NO_NAME,QUOTED_EMAIL_TEXT,REFERENCES
	version=2.55
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
Xref: archiver1.google.com comp.std.c++:20592



"Stefan Heinzmann" <stefan_heinzmann@yahoo.com> wrote in message
news:95e0e5ef.0308060330.28aefaae@posting.google.com...
[snip]
> Wouldn't that make the usage of standard algorithms and standard
> containers both easier and safer? Ideally, each container wouldn't
> just define its iterator type but also its iterator range type through
> a typedef. Algorithms operating on a range would not take two separate
> iterator arguments but a single range argument instead.

As I see it, the container/iterator coorporation is very generic and useful,
but its sometimes a bit
tedious and it doesn't go well in hand with functional style programming.

At boost we have been working on some new "container" algortihms, algorithms
that take an iterator range
as a single argument. This enables us to pass containers, pairs of iterator,
arrays as a single argument
�to algortihms which underneith will (mostly) simply forward to the current
algortihm.

For mutating algorithms the full benefit will first come if/when
move-semantics are intriduced. It's been a while since I looked into it, but
I think mojo is cannot be applied here.

Anyway, you can see some implementation in the boost sandbox:. Look for
these files

boost/sequence_algo/container_traits.hpp
boost/sequence_algo/container_algo.hpp

container_traits<> is the tool you need to treat types as iterator ranges.

I now Alisdair Meredith is trying (or tried?) to get an iterator_range
concept into the standard together the
proposed iterator adapter lib.

We had a discussion back then where I briefly sketched this
http://www.cs.auc.dk/~nesotto/iterator_range.html.

regards

Thorsten





---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



