This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GSoC] __enable_shared_from_this_helper


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]