6 ms·
This glosses over "rvalue references", which is roughly what Rust does when you pass a parameter without any further qualification (references, boxes).
by heinrich5991 10y ago
This glosses over "rvalue references", which is roughly what Rust does when you pass a parameter without any further qualification (references, boxes).
- ycmbntrthrwaway 10y agoCan you give an example? Is void foo(T&& value) { ... } similar to fn foo(value: T) { ... } ?
- krona 10y agoBoth are similar in the sense that `foo` owns `value`, yes. Or at least that's the idea. In C++, it's up to the author of T to implement such semantics (through its move constructor) correctly for non-trivial types.