Move Constructors - Converting Lvalues to Rvalues
Timon Gehr
timon.gehr at gmx.ch
Mon Sep 30 19:37:04 UTC 2024
On 9/30/24 18:05, Walter Bright wrote:
>
> So, does anyone have any brilliant ideas for how to make the compiler
> treat an lvalue as an rvalue?
Well, with DIP1040 this is automatically the case for last uses.
So in your code example:
```
void phone(S s)
{
S t = s; // copy constructor
}
```
The comment is actually inaccurate with DIP1040. With DIP1040, this is a
move.
Otherwise, maybe expose explicit moves. This is useful generally. Can
just be `move(x)`, where `move` is either special, or is a function with
a "move by default" attribute on its parameter, as we discussed previously.
More information about the Digitalmars-d
mailing list