Is boost::make_shared obsolete now? Haven't found its definition in 1.35.
Its in the 1.4 docs: http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/make_shared.html
It appears to have been added in version 1.39
std::make_shared is also available in C++11. Please note that make_shared is more than just a convenience function. Take a look at the following code fragment:
make_shared<foobar>(1, 2);
shared_ptr<foobar>(new foobar(1, 2));
Both statements create a foobar object and construct a shared_ptr. However, the former avoids a memory allocation for the shared counter, because a single memory chunk will be used for the counter and the foobar object. This is not possible with the second statement, because the memory for foobar is allocated before the shared_ptr is constructed.
What I want to say: No, make_shared is not obsolete, because it provides a very useful optimization.
Did a bit of research today, and it seems that make_shared actually was added to 1.36.0 (in 1.35.0 there is no such header), but the interesting thing is that there is no single mention in What's new about this change - at least I could not find it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With