mercredi 10 novembre 2021

Move a std::map vs move all the elements of a std::map

std::map<int, Obj> mp;
// insert elements into mp

// case 1
std::map<int, Obj> mp2;
mp2 = std::move(mp);

// case 2
std::map<int, Obj> mp3;
std::move(std::begin(mp), std::end(mp), std::inserter(mp3, std::end(mp3));

I am confused by the two cases. Are they exactly the same?

Aucun commentaire:

Enregistrer un commentaire