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 29/04/15 20:28 -0700, Tim Shen wrote:
Is it still as usable if we do a rebind here? [17.6.3.5] seems to make
rebind optional, and there may not exist a char allocator. This was my
major concern.

All allocators must support rebinding. If they don't provide a rebind
member then allocator_traits will provide it, and if that doesn't work
it's ill-formed and the allocator can't be used with allocate_shared.

Allocators are allowed to restrict the types they can be instantiated
with, so Alloc<char>::allocate() or Alloc<char>::deallocate() might
fail to compile, but that's not our problem. Users who define
allocators like that can't use them with allocate_shared<T[]>.

But yeah, for implementing 2) you still need to propagate the length.


Why? Am I missing something?

No, it's me who missed something, since I didn't fully follow your
pre-GSoC communications :) I'm not sure how well Fan is on track? Can
Fan briefly illustrate your progress?

As Jon explained, we don't need to explicitly pass around the length,
as long as a customized deleter can take care of it.

Yes, a custom deleter *must* be able to take care of it, because only
the pointer is passed to the deleter.

If the array was actually created by calling a.allocate(n) on some
allocator then n must be stored in the deleter, so it's not
shared_ptr's responsibility to store it.


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