Move Constructors - Converting Lvalues to Rvalues
Dukc
ajieskola at gmail.com
Wed Oct 2 08:49:39 UTC 2024
On Tuesday, 1 October 2024 at 17:37:37 UTC, Walter Bright wrote:
> On 10/1/2024 12:27 AM, Dukc wrote:
>> Why special syntax? `move` is a DRuntime function so it's
>> expected that it can have special semantics, even without
>> special syntax.
>
> Converting to an rvalue is an enabler of other functions, too,
> not just move. __rvalue is a building block, not a complete
> function.
`move` _is_ the `__rvalue` building block, at least in principle.
It accepts an lvalue and returns a rvalue, without executing the
destructor or move constructor of the type in question.
It does set the lvalue to it's `.init` value, but this can be
elided by the optimiser if the lvalue is not used again, assuming
the destructor doesn't side-effect in any way.
More information about the Digitalmars-d
mailing list