From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-08-13 14:16:47
>From: "Peter Dimov" <pdimov_at_[hidden]>
>From: "Terje Slettebø" <tslettebo_at_[hidden]>
> And MPL has a uniform iterator interface. _This_kind of uniformity, a
> uniformity of interface (rather than implementation, such as standardising
> on _one_ sequence), ensures interoperability, removes duplication, and
> the design open-ended. Oh, and did I mention you get a free doll, as well?
> :) And a picture of the company president. :) Furthermore, there's a
> money-back guarantee. Uh, come to think of it, it's free already, never
> mind. :)
>Does MPL have an uniform iterator interface? Many MPL algorithms take
>sequences, not iterators.
You're right about that. Presumably, there's some reason behind this design.
Perhaps they figured it would be more common to pass sequences than
iterators to them. In any case, the interface that the algorithms expect, is
a uniform iterator interface, given by the sequence. Some of them also use
iterators directly, when it's not specifying a sequence, but just a position
in a sequence.
>You can make a sequence out of two iterators,
Yes, you have the simple wrapper iterator_range, defined simply as this:
, typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Last)
typedef iterator_range_tag tag;
typedef iterator_range type;
typedef First begin;
typedef Last end;
>true but what kind of sequence does this produce?
If the iterators are from the same sequence, this should produce a sequence
of the same kind as which they came from. Specifically, it doesn't create a
new sequence, as shown above, but instead provides a wrapper for the
iterators, so they behave like a sequence to algorithms.
>MPL sequences have
>different characteristics. If you sort the first half of a sequence S, what
>properties does the resulting sequence have?
It depends on how the sort is implemented, I guess (one isn't present in the
library, yet). As you know, C++ MP isn't mutating, so such a sort would
return a sorted copy of the half of the sequence. Likely stored in the same
kind of sequence as the original, to preserve the characteristics of the
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk