xvalue and std::move in D
Mike Parker
aldacron at gmail.com
Thu Mar 6 03:28:29 PST 2014
On 3/6/2014 8:21 PM, Edwin van Leeuwen wrote:
>
> and call it as follows:
>
> std::vector<double> v;
> v = add_to_vector( 1.2, std::move( v ) );
>
> I know I could do the same by passing a reference value, but this makes
> it explicit that I am changing v, while being as efficient as passing a
> reference (since it just reuses the memory allocated to v instead of
> making a copy).
>
> Is this possible in D? I had a look through many tutorials and some of
> the docs, but could not find out how to do it.
>
> Any suggestions would be appreciated.
See std.algorithm.move
http://dlang.org/phobos/std_algorithm.html#move
More information about the Digitalmars-d-learn
mailing list