[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:45:11 PDT 2020
mclow.lists marked an inline comment as done.
mclow.lists added inline comments.
================
Comment at: libcxx/include/any:370
static _Tp& __create(any & __dest, _Args&&... __args) {
- _Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
+ typedef allocator<_Tp> _Alloc;
+ typedef allocator_traits<_Alloc> _ATraits;
----------------
EricWF wrote:
> Can `std::allocator` have behavior that observably differs from this code? (which is just the default std::allocator inlined).
Sure. A user-specialization of `std::allocator` can do most anything, as long as it actually constructs the object as well.
Register it in a global registry, for example.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81133/new/
https://reviews.llvm.org/D81133
More information about the libcxx-commits
mailing list