vendredi 28 septembre 2018

std::vector move instead of swap to clear

Do I understand right, that with introduction of move semantics in C++11, move can be used instead of swap-to-clear idiom?

std::vector<T>().swap( v );
// VS
v = std::move( std::vector<T>() );

Is the second approach guaranteed to clear storage?

Aucun commentaire:

Enregistrer un commentaire