[Cs3] In class question
Mikhail Nesterenko
mnestere at kent.edu
Mon Sep 15 15:29:32 EDT 2025
> Can functions return rvalue refrences?
> Such as
> int &&bingus() {
> return 5+6;
> }
Officially, returning rvalue references is allowed similar to lvalue
reference or pointers.
However, the above code returns a danging (loose) reference because
the value 5+6 is deallocated after function return.
On stackoverflow, there is an interesting discussion about the use of
functions returning lvalue references here:
https://stackoverflow.com/questions/1116641/is-returning-by-rvalue-reference-more-efficient
Thanks,
--
Mikhail
More information about the cs3
mailing list