This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [GSoC] __enable_shared_from_this_helper
- From: Tim Shen <timshen at google dot com>
- To: Fan You <youfan dot noey at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, Tim Shen <timshen91 at gmail dot com>, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 28 Apr 2015 22:22:40 -0700
- Subject: Re: [GSoC] __enable_shared_from_this_helper
- Authentication-results: sourceware.org; auth=none
- References: <CALvpekGVZEMtGN5MKVXrArG5cKJhqDQjsfgjdFZYk0=H=7+V_Q at mail dot gmail dot com> <20150428215024 dot GF3618 at redhat dot com> <20150428215349 dot GG3618 at redhat dot com> <CALvpekGhEJfEWdHmtOyco-Ua=sPjk4yhpFFE7Fzffy9cTmnVbA at mail dot gmail dot com> <CAG4ZjN=a9nvQ3CgqRiSze-fbUvh0u69WQQdehS5+mFXsvtSP=A at mail dot gmail dot com>
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