[GSoC] __enable_shared_from_this_helper
Jonathan Wakely
jwakely@redhat.com
Tue Apr 28 21:53:00 GMT 2015
On 28/04/15 22:50 +0100, Jonathan Wakely wrote:
>On 28/04/15 16:48 -0400, Fan You wrote:
>>2. Also, I am little bit unsure about what _Sp_counted_ptr_inplace does.
>>
>>It seems to me that when I call allocate_shared<>(); it construct a
>>single _Sp_counted_ptr_inplace object.
Right.
>>Then, _Sp_counted_ptr_inplace is taking charge of allocating the
>>needed memory for shared_ptr by using the given allocator.
No, all the memory is already allocated by the time the
_Sp_counted_ptr_inplace's lifetime begins.
_Sp_counted_ptr_inplace contains the shared_count but also a buffer
where the object will be created.
When you use _Sp_counted_ptr the object is allocated separately, but
when you use _Sp_counted_ptr_inplace the object lives inside the
_Sp_counted_ptr_inplace so there is no separate allocation.
More information about the Libstdc++
mailing list