I have TTempTable
class with move symantics. I wrote
TTempTable&& MyFunction() {
TTempTable tmp = f(...);
...
return std::move(tmp);
}
and got no compiler errors.
Was this correct?
Tell the clerk you want to return the item. Go to the returns department if there is one, or to a cashier. Smile and explain that you want to return an item and why. Remember to be friendly.
Tell the clerk you want to return the item. Smile and say, "Hi, I want to return this item which I bought last week." Show the clerk the item and your receipt. Don't delay returning the item. Some stores allow returns but only for a certain amount of time.
No, it is not correct.
You're returning a reference to a local variable. That reference is dangling.
Like any dangling thing, the compiler won't [always] diagnose it for you.
Return by value, and remove the std::move
(it's redundant and inhibits elision).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With