[libcxx-commits] [PATCH] D81133: Use allocator_traits to consistently allocate/deallocate/construct/destroy objects in std::any
Marshall Clow via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 4 08:12:08 PDT 2020
mclow.lists marked an inline comment as done.
mclow.lists added inline comments.
================
Comment at: libcxx/include/any:382
static void __destroy(any & __this) {
- _Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
- __value.~_Tp();
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
----------------
EricWF wrote:
> Is it the case that the allocator which allocated this memory is always equal to a default constructed allocator? If not, this is UB.
Remember that we're not talking about an arbitrary allocator, but `std::allocator`
(It can be a user specialization, but it's still `std::allocator`)
See http://eel.is/c++draft/allocator.globals. They're always equal.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81133/new/
https://reviews.llvm.org/D81133
More information about the libcxx-commits
mailing list