Re:C++: Return value optimization vs. std::move
by thrownaway2424 on Monday July 20, 2015 @12:47PM
(#9917250)
Yeah I realized after the fact that the example is pointless, but I was trying to adhere to the original post, which is also pointless. Why would you construct two BigObject when you know you will discard one of them unused? It's dumb.
In code like this, you should just use make_unique, in which case the BigObject is constructed in place, and unique_ptr can be RVO'ed: