On 2010-07-21 13:00:56 -0400, Peter Alexander <[email protected]> said:

An example of an algorithm that would take a cursor is
insertBefore. There is no reason for it to accept a range, because
you are not traversing elements. You just want to insert something
before some single point in the range.

From what I understand, you'd like something like this to work:

        auto range = container[];
        auto sortOfIterator = range.front;
        container.insertBefore(sortOfIterator);

Couldn't this be acheived with a 'smart reference' struct? Something like this:

        struct SmartRef(T) {
                ref T value() { return *data.ptr; }
                alias value this;

        private:
                SortOfIteratorData data;
        }

Then you define front (and any function normally returning a reference) as:

        SmartRef!T front();

and it should work as usual, in addition to carrying the extra data you want in your 'iterator'.

It's totally transparent (as long as the user uses 'auto' for its references), but it's more burden to the implementor.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to