[all-commits] [llvm/llvm-project] 39c879: [libc++] Use allocator_traits to consistently allo...

Marshall Clow via All-commits all-commits at lists.llvm.org
Tue Sep 15 08:05:20 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 39c8795141703a7d8313b2448d9d34e856df0b85
      https://github.com/llvm/llvm-project/commit/39c8795141703a7d8313b2448d9d34e856df0b85
  Author: Marshall Clow <mclow.lists at gmail.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M libcxx/include/any
    A libcxx/test/libcxx/utilities/any/allocator.pass.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list