What ever happened to move semantics?

Timon Gehr timon.gehr at gmx.ch
Wed Feb 28 14:22:48 UTC 2024


On 2/28/24 15:17, Timon Gehr wrote:
> ...
> What is missing from the DIP?
> ...
> 

19. Explicit moves.

There is no way to force that a given occurrence of a variable is the 
last use and is moved. We can use std.algorithm.move, but the DIP as 
specified would just move a copy if something is used again.

What I would like to see is:

```d
void main(){
     S s;
     foo(move(s));
     auto t=s; // error, `s` has been moved
     S s; // ok, can redeclare `s`
}
```

Maybe there needs to be a parameter annotation that forces a move, then 
`move` can be implemented in terms of that.


More information about the Digitalmars-d mailing list