Sorting a zipped range
Timon Gehr
timon.gehr at gmx.ch
Thu Feb 27 15:42:42 PST 2014
On 02/27/2014 10:09 PM, Ben Jones wrote:
>
> My question is: which features of the D range abstraction allow zip to
> work the way we expect?
Assignable elements of a range do not need to be addressable.
> What C++isms were left behind to make this work?
In C++, iterators should implement operator-> which must return a
pointer to data, and unary operator*, which should return a reference
if it is to be assignable. This makes the iterator abstraction less
flexible.
I.e. it is a consequence of
- desire to use pointer-like syntax for iterators
- weak support for hooking into the corresponding syntactic constructs
Phobos eg. allows retrieval of and assignment to a range's front element
to be implemented in distinct methods that can execute arbitrary code.
Zip uses such facilities to distribute assignments to its range elements
back to each source range.
More information about the Digitalmars-d-learn
mailing list