Re: std::make_shared creating a single block?
Am 21.11.2012 23:59, schrieb Andy Champ:
> I came across this reference:
> "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 . So, I'm surprized to read that you think Microsoft
implements make_shared to use two memory allocations.
|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.