[libcxx-commits] [PATCH] D91201: [libc++] Call allocator_traits construct() and destroy() in allocate_shared

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 10 13:17:23 PST 2020


zoecarver added a comment.

This is my bad; I should have made this more clear or changed the order of the patches. One of the primary reasons I'm pushing on D62760 <https://reviews.llvm.org/D62760> is because it adds `__shared_ptr_aligned_block` and the preliminary logic to use it. This is necessary to support array types in `make_shared` and `allocate_shared`, and I thought it would be easier if there was a separate patch to implement `__shared_ptr_aligned_block`.

That being said, `make_shared` and `allocate_shared` will have different overloads for array types, so if we can get away with using `__shared_ptr_emplace` in the non-array overloads, we should 100% try to do that to simplify the implementation (as is done in this patch).



================
Comment at: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_construct.pass.cpp:28
+static bool destroy_called = false;
+static unsigned allocator_id = 0;
+
----------------
In either patch, it would probably be a good idea to move these into `MyAllocator` so we can make sure that the correct specialization is setting them. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91201/new/

https://reviews.llvm.org/D91201



More information about the libcxx-commits mailing list