![]() |
Re: std::make_shared creating a single block?
Am 21.11.2012 23:59, schrieb Andy Champ:
> I came across this reference: > > <http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared> > > "This function allocates memory for the T object and for the > shared_ptr's control block with a single memory allocation. In contrast, > the declaration std::shared_ptr<T> p(new T(Args...)) performs two memory > allocations, which may incur unnecessary overhead." As Luca said, it's encounraged, not required. > The Microsoft compilers allocate two blocks for this, one for the > control block and one for the object. Are you really sure? If I remember correctly, Stephan T. Lavavej -- one of Microsoft's C++ standard library devlopers -- explained how this one-allocation trick works in one of his pubpicly available lecture videos [1]. So, I'm surprized to read that you think Microsoft implements make_shared to use two memory allocations. Cheers! SG [1] <http://channel9.msdn.com/shows/Going+Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-3-of-n/> |
| All times are GMT. The time now is 07:25 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.