[libc++] Use allocator_traits to consistently allocate/deallocate/construct/destroy...
authorMarshall Clow <mclow.lists@gmail.com>
Tue, 15 Sep 2020 13:56:03 +0000 (09:56 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 15 Sep 2020 15:04:59 +0000 (11:04 -0400)
commit39c8795141703a7d8313b2448d9d34e856df0b85
tree41df119b79cff32be10a82cae47b5826c9bbeadf
parent8985755762a429573af2ce657274772339d3b9db
[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
libcxx/include/any
libcxx/test/libcxx/utilities/any/allocator.pass.cpp [new file with mode: 0644]