On 9/29/10 6:22 PDT, Steven Schveighoffer wrote:
std.algorithm.sort seems to require lvalue access to elements of a
range, presumably so it can call swap on two elements during sorting. So
while a range can technically allow changing of data, it cannot be
passed to swap.

e.g.

struct myrange
{
@property T front() {...}
@property T front(T t) {...}
void popFront() {...}
@property bool empty() {...}
myrange opSlice(size_t low, size_t hi) {...}
@property size_t length() {...}
}

Good news - you should be able to use sort on sealed ranges if they define moveFront, moveBack, and moveAt. Look e.g. at Zip, it's also sealed yet you can sort Zips no problem.

This is a relatively new addition.

Andrei

Reply via email to