I think you should never std::move return values. Afaik every modern compiler does NRVO and manually moving prevents it. And on the offchance you need to use a compiler that optimizes less, that one copy most likely is the least of the performance concerns.
Afaik every modern compiler does NRVO and manually moving prevents it.
Yeah this is what bothers me. std::move could make things worse, but not if the alternative is a copy. But you’re probably right that any self-respecting compiler nowadays would do NRVO.
I think you should never
std::move
return values. Afaik every modern compiler does NRVO and manually moving prevents it. And on the offchance you need to use a compiler that optimizes less, that one copy most likely is the least of the performance concerns.Yeah this is what bothers me.
std::move
could make things worse, but not if the alternative is a copy. But you’re probably right that any self-respecting compiler nowadays would do NRVO.