On 12/21/2016 02:59 PM, Nordlöw wrote:
On Wednesday, 21 December 2016 at 21:02:17 UTC, Ali Çehreli wrote:
void f(Rs...)(Rs ranges)
{
    import std.functional: forward;
    g(forward!ranges);

Interesting. How does this differ from std.algorithm.mutation.move()
when R.length is 1?

Why do we have both `move` and `forward`, then?

Here is what I understand after glancing the documentation again:

* 'move' is for moving state, which may necessitate destroying the source if leaving it behind can cause harm. For example, if the object has a destructor or post-blit, then the source should be "silenced" :) to prevent doing it twice.

* As an added bonus, 'move' seems to be one spot (the only?) that D validates that a struct object does not have internal pointers.

* 'forward' is for forwarding arguments to functions. It seems to an answer to "perfect forwarding" that I know from C++: maintain by-ref'ness of arguments when forwarding them to other functions.

Ali

Reply via email to