[libcxx-commits] [libcxx] [libc++] Correctly handle custom deleters in hardened unique_ptr<T[]> (PR #110685)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 1 13:16:30 PDT 2024
ldionne wrote:
>
> How does would that API help? Would it call `new []` internally for `T[]`s and require the custom deleter to eventually call `delete[]`?
`std::make_unique` currently looks like
```
auto ptr = std::make_unique<T[]>(10); // allocated using new T[10]
```
We know the size of the allocation because it gets passed to the function. The same would be true with a custom deleter, e.g.
```
auto ptr = std::make_unique<T[]>(10, mydeleter);
```
If that were the case, we could stash the size passed to `make_unique` inside the `unique_ptr` when we have the right ABI configuration. However, this doesn't help the case where we don't have the "fat" ABI configuration at all.
https://github.com/llvm/llvm-project/pull/110685
More information about the libcxx-commits
mailing list