I have the following function:
T foo();
And, in another function, I play with the returned value T, for example:
const T& t = foo();
or
T&& t = foo();
I want to ask:
Are both equivalent?
It is clear, what is the difference between these two approaches?
I know that in the first approach, the temporal value of the lifetime corresponds to the reference lifetime. Does the same thing happen when using the rvalue reference?
Should I even use const rvalue ( const T&&) reference ?
I use the first approach, this is what I'm used to, and it treats me well. I am still wrapping my head with rvalue and C ++ 11 links.
source
share