3 ms·
It would not break, but it’s still a logical fallacy to std::move something returned by value, no? Or is there a valid use case here? I strictly use std::move
by w0utert 6y ago
It would not break, but it’s still a logical fallacy to std::move something returned by value, no? Or is there a valid use case here?
I strictly use std::move in case of explicit transfer of ownership, and not to try to outsmart the compiler to ‘optimize’ something. As the article shows the compiler is smart enough to do all this by itself, it doesn’t need to be told to try to elide copies. But maybe I’m missing some valid use case where it would make sense to add the std::move in these kinds of situations?
- tylerhou 6y agoYou're right, there's not really a point in std::move-ing something returned by value because the something is already a rvalue.