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 calls are identical. Here make_shared will create a new shared_ptr, and then this pointer will be moved into the container both in push_back and emplace_back. Is this correct, or will there be some difference?
vector<T>::push_backhas aT&&overload, which does the same as thevector<T>::emplace_backT&&version.The difference is that
emplace_backwill perfect-forward any set of arguments to theT's constructor, whilepush_backonly takesT&&orT const&. When you actually pass aT&&orT const&the standard specification of their behaviour is the same.