[GSoC] __enable_shared_from_this_helper

Tim Shen timshen@google.com
Wed Apr 29 05:22:00 GMT 2015


On Tue, Apr 28, 2015 at 10:16 PM, Tim Shen <timshen@google.com> wrote:
> 1) If you implement shared_ptr<int[]> in terms of shared_ptr<int> with
> a special allocator, then this allocator needs to carry the length and
> be able to wrap an user-specified allocator:
>     template<typename _Alloc>
>     class __allocator_array_wrapper
>     {
>     public:
>       /* typedefs */
>     public:
>       /* ... */
>       pointer allocate(size_type __n, /*...*/)
>       {
>         _GLIBCXX_DEBUG_ASSERT(__n == 1);
>         return _M_alloc.allocate(_M_length, /*...*/);
>       }
>
>       void deallocate(pointer __p, size_type __n)
>       {
>         _GLIBCXX_DEBUG_ASSERT(__n == 1);
>         _M_alloc.deallocate(__p, _M_length);
>       }
>       /* ... */
>     private:
>       size_t _M_length;
>       _Alloc _M_alloc; // just for illustration here; may need ebo.
>     };

If you used this, I don't see any reason you even need to touch
_Sp_counted_base. So the 3 suggestions above on _Sp_counted_base
supporting array don't apply here.


-- 
Regards,
Tim Shen



More information about the Libstdc++ mailing list