Move Constructors - Converting Lvalues to Rvalues

Timon Gehr timon.gehr at gmx.ch
Tue Oct 1 20:06:54 UTC 2024


On 10/1/24 06:55, Per Nordlöw wrote:
> On Monday, 30 September 2024 at 19:37:04 UTC, Timon Gehr wrote:
>> 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.
> 
> Considering the template-complexity of the current implementation of 
> `core.lifetime.move` it will beneficial compile-time wise to make `move` 
> become a builtin. Ideally I would like to have a special syntax for 
> converting an l-value to an r-value.

I think in case we did go the function route, I think any implementation 
of `move` that is much more complex than the following is a failure:

```d
auto move(T)(@moved T arg)=>arg;
```

Of course, going with a built-in makes sense too.


More information about the Digitalmars-d mailing list