[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:05:26 PST 2020


zoecarver added inline comments.


================
Comment at: libcxx/include/memory:4089
+#if _LIBCPP_STD_VER > 17
+    allocator_traits<_ControlBlockAllocator>::construct(__cb_alloc, _VSTD::addressof(*__guard.get()), __a, _VSTD::forward<_Args>(__args)...);
+#else
----------------
I don't think this works. We need to call `allocator_traits<_Tp>::construct` which requires us to have a pointer of type `_Tp*` which is why D62760 has to use `__shared_ptr_pointer` instead of `__shared_ptr_emplace`.

`allocator_traits<_ControlBlockAllocator>::construct` isn't sufficient, see the relevant part of the standard: https://eel.is/c++draft/util.smartptr.shared#create-7.5


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