vendredi 13 août 2021

Is it still necessary to use std move even if auto && has been used

As we know, STL usually offered two kinds of functions to insert an element: insert/push and emplace.

Let's say I want to emplace all of elements from one container to another.

for (auto &&element : myMap)
{
    anotherMap.emplace(element);  // vs anotherMap.empalce(std::move(element));
}

In this case, if I want to call the emplace, instead of insert/push, must I still call std::move here or not?

Aucun commentaire:

Enregistrer un commentaire