mardi 19 janvier 2021

Using make_shared with emplace_back and push_back

some_vector.push_back(make_shared<ClassName>());
some_vector.emplace_back(make_shared<ClassName>());

I want to check that my understanding is correct that for make_shared and in general for all other functions that returns an object those two call are identical. Here make_shared will create new shared_ptr, and than this prt will be moved into the container both in push_back and emplace_back. Correct? Or there still will be some difference?

Aucun commentaire:

Enregistrer un commentaire