On Friday, April 11, 2025, Ell wrote:
I mean that wanting to move a variable upon last use is independent of
whether it's a reference or a function parameter. In your example, why
should you need to introduce a reference in the first place? You might
want to explicitly mark the variable somehow to opt into this
behavior... or maybe not?
The 'mark' you speak of could be the same as how I've suggested marking a reference, i.e.:
string &&&s("Hello World");
string &&&s2 = "HelloWorld";
This would be similar to how we programmed before C++11, back when we extended the lifetime of a temporary object by binding it to a const reference, as follows:
string const &s = FuncReturnsStringByValue();
The above line nowadays is simply written as:
string s = FuncReturnsStringByValue();