std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]

Stanislav Blinov stanislav.blinov at gmail.com
Sat Jun 20 17:19:49 UTC 2020


On Saturday, 20 June 2020 at 17:02:56 UTC, Avrina wrote:

> Most of the algorithms in Phobos don't call front() multiple 
> times and they make a copy. It is really annoying as this 
> prevents using non copyable types or those that need to be 
> moved, eg similar to unique_ptr. What you are suggesting 
> doesn't sound all that better, it just cements what is already 
> common place in Phobos into the API.

On the contrary. Non-copyable types are *the* target for a 
hypothetical fetchNext(ref T target). Which would be @system, and 
you'd be calling it with an uninitialized value.
Although a one-pass consuming range could also be built with the 
`moveFront` interface.

That said, some algorithms do indeed require an improvement 
(toward moving instead of copying). `sort` just recently got such 
improvement courtesy of MoonlightSentinel.


More information about the Digitalmars-d mailing list