xvalue and std::move in D

Edwin van Leeuwen bla at bla.bla
Thu Mar 6 04:39:57 PST 2014


On Thursday, 6 March 2014 at 12:10:40 UTC, Mike Parker wrote:
> On 3/6/2014 8:49 PM, Edwin van Leeuwen wrote:
>> On Thursday, 6 March 2014 at 11:28:21 UTC, Mike Parker wrote:
>>>
>>> See std.algorithm.move
>>>
>>
>> Thank you, can't believe I missed that. How do I specify that 
>> the
>> function expects a temporary/xvalue (&&) parameter though?
>
> D doesn't have anything like that. The compiler will generally 
> move for you when possible. Passing an RValue to a function 
> will be done as a move. When returning structs from a function, 
> they're moved. For LValues, it's up to the caller to make the 
> move with std.algorithm.move. There's been a good deal of 
> discussion here in the NG about this. Hit google with 'dlang 
> move semantics' and you'll get some hits. There's also Ali's 
> presentation (video[1] and slides[2]) from last year's DConf.
>
> [1] http://www.youtube.com/watch?v=mPr2UspS0fE
> [2] http://dconf.org/2013/talks/cehreli.pdf

Thank you for those links/pointers. I'll have a look at those.


More information about the Digitalmars-d-learn mailing list