[libc++] Use allocator_traits to consistently…

Authored by mclow.lists on Sep 15 2020, 6:56 AM.


[libc++] Use allocator_traits to consistently allocate/deallocate/construct/destroy objects in std::any

https://llvm.org/PR45099 notes (correctly) that we're inconsistent in memory
allocation in std::any. We allocate memory with std::allocator<T>::allocate,
construct with placement new, destroy by calling the destructor directly, and
deallocate by calling delete. Most of those are customizable by the user,
but in different ways.

The standard is silent on how these things are to be accomplished.
This patch makes it so we use allocator_traits<allocator<T>> for all
of these operations (allocate, construct, destruct, deallocate).
This is, at least, consistent.

Fixes https://llvm.org/PR45099.

Differential Revision: https://reviews.llvm.org/D81133