`@rvalue ref` and `@universal ref`

IchorDev zxinsworld at gmail.com
Mon Jul 29 05:52:40 UTC 2024


On Wednesday, 3 July 2024 at 11:50:19 UTC, Quirin Schroll wrote:
> Add two function parameter attributes `@rvalue` and 
> `@universal` which must be used together with `ref` (similar as 
> `auto` is only valid as `auto ref`).

This would be really useful for sure, as long as escaping rvalue 
references isn’t possible, so I guess it’d have to work like 
scope?
Also I’m not sure about the at-attribute-based syntax. It makes 
the feature feel like an afterthought, even though this 
functionality is very useful. Perhaps a better solution 
syntax-wise could be to use `in` as the ‘rvalue’ attribute, and 
`auto in` could be the ‘universal’ attribute. So then:
- `@rvalue` —> `in`
- `@rvalue ref` —> `in ref`
- `@universal ref` —> `auto in ref`
- `@universal auto ref` —> `auto in auto ref`

This way it’s both shorter to write, more consistent with 
existing function attributes, and we can **finally** make `in` do 
something useful by default.


More information about the dip.ideas mailing list