Move Constructors - Converting Lvalues to Rvalues
Imperatorn
johan_forsberg_86 at hotmail.com
Wed Oct 2 19:05:12 UTC 2024
On Wednesday, 2 October 2024 at 18:00:29 UTC, Walter Bright wrote:
> On 10/1/2024 1:06 PM, Timon Gehr wrote:
>> [...]
>
> The major difference between @move and __rvalue is the former
> is attached to the parameter, and the latter is attached to the
> argument. This might seem a distinction without a difference,
> but this has large implications with how overloading works.
>
> [...]
The intrinsic is clearly best
```d
struct S {
this(ref S) { /* Copy */ }
this(S) { /* Move */ }
}
void main() {
S t;
S s1 = t; // Copy
S s2 = __rvalue(t); // Move
```
More information about the Digitalmars-d
mailing list