There are some functions in the STL which start with the make_
prefix like std::make_pair
, std::make_shared
, std::make_unique
make_unique
hides from you "raw" pointer, what's usually a good thing - it's less error prone.
make_shared
may improve memory allocation for shared_ptr
instances. Normally when you use shared_ptr
constructor it will allocate memory twice, first for instance of X
and second for it's internal data (e.g. reference counter). make_shared
enables optimization - it will create single, internal structure comprising both X
and reference counter, hence it will perform single memory allocation. And same as before it hides raw pointers.