Quick A: So easily that it's automatic... just return a value, not a reference.
How does return by rvalue reference work?
Just when I thought I kind of understand rvalue reference, I ran into this problem. The code is probably unnecessarily long, but the idea is quite simple. There is a
main()
function, andreturnRValueRef()
function.[...] AClass && returnRValueRef() { AClass a1(4); return move(a1); } int main() { AClass a; a = returnRValueRef(); }
Add a Comment
Comments are closed.