3 ms·
> explicitly calling move can be less efficient than implicitly relying on copy elision Sure, in the sense that non-zero is greater than zero. But move constru
by kentonv 11y ago
> explicitly calling move can be less efficient than implicitly relying on copy elision
Sure, in the sense that non-zero is greater than zero. But move constructors are almost always basically a memcpy() sometimes followed by some zeroing of the old data, never heap allocation nor expensive atomic ops. IMO it's not worth worrying about. Much better to accidentally invoke a redundant move because you specified std::move() when you didn't have to than to accidentally invoke a redundant copy because you thought RVO would kick in but it didn't.
- shmerl 11y agoThat may be, though code becomes more cluttered with moves as well.