mercredi 27 mai 2020

How to comprephend these ways could eliminate most need for explicit std::move? Could anybody make it clear by some simple examples?

How to comprephend these ways(including not making variables’ scopes needlessly large, writing short functions that return values, returning local variables) could eliminate most need for explicit std::move?

Could anybody make it clear by some simple examples?I am a novice in C++.I would be grateful for any hint on this question. For your convenience, I post all the quotes below.

Moving is done implicitly when the source is an rvalue (e.g., value in a return treatment or a function result), so don’t pointlessly complicate code in those cases by writing move explicitly. Instead, write short functions that return values, and both the function’s return and the caller’s accepting of the return will be optimized naturally. In general, following the guidelines in this document (including not making variables’ scopes needlessly large, writing short functions that return values, returning local variables) help eliminate most need for explicit std::move.

Aucun commentaire:

Enregistrer un commentaire