[PATCH] D30837: [libcxx] Support for shared_ptr<T()>
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 13 14:14:07 PDT 2017
erik.pilkington added inline comments.
================
Comment at: include/memory:3606
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{
----------------
EricWF wrote:
> I would prefer using an entirely different allocator type, not a specialization of `std::allocator`.
>
> Re-naming this class to `__shared_ptr_dummy_rebind_allocator` and moving it closer to `__shared_ptr_default_allocator` would be good.
Unfortunately, for this approach to work we have to specialize `std::allocator` because we use the `template <class _Up> allocator(const allocator<_Up> &)` constructor at `__shared_ptr_pointer::__on_zero_shared_weak`.
If specializing `std::allocator` is a problem, I suppose we could pass in a special entirely empty struct as an "allocator" to `__shared_ptr_pointer` when necessary, then metaprogram our way out of using the converting constructor at `__shared_ptr_ptr::__on_zero_shared_weak`. I think the current approach is simpler though.
https://reviews.llvm.org/D30837
More information about the cfe-commits
mailing list