dimanche 16 juillet 2017

When should I prefer `shared_ptr` to `make_shared`?

As pointed in answers to Difference in make_shared and normal shared_ptr in C++, make_shared outperforms shared_ptr in most cases.

Then why does C++ standard define both shared_ptr and make_shared together? Are there any cases at which I should prefer shared_ptr to make_shared or even at which I can only use shared_ptr but not make_shared?

Aucun commentaire:

Enregistrer un commentaire