4 ms·
Also, if you write > return std::move(ret); it can interfere with return value optimisation (RVO). There might be cases where the move makes sense but to my u
by dryanau 4y ago
Also, if you write
> return std::move(ret);
it can interfere with return value optimisation (RVO). There might be cases where the move makes sense but to my understanding it's enough to just use return.
It's very much possible to take advantage of modern C++ move semantics without an explicit call to move. Maybe you return a unique_ptr created by make_unique in a factory method, or call swap() on a moveable object, etc. I rarely need to write std::move to take advantage of modern C++ although it took some self-education about rvalues etc to learn how to do it.