[libcxx-commits] [libcxx] Reapply "[libc++] Optimize vector growing of trivially relocatable types" (PR #80558)

Fangrui Song via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 5 16:44:24 PST 2024


MaskRay wrote:

> @nico @gribozavr is correct that this is because of `vector<const T>`. I think I'd consider this a bug for now, but IMO we should just remove the `allocator<const T>` extension that allows this. It has bitten at least me way too often when working on `vector`, and isn't supported by any other major vendor: [godbolt.org/z/8MPaP94cz](https://godbolt.org/z/8MPaP94cz). @ldionne Any thoughts on this?

The clang-tidy check `portability-std-allocator-const` patch (https://reviews.llvm.org/D123655) contains some notes and can be useful if your code base has a lot of offending code.

---

We internally do use `portability-std-allocator-const` and the offending code does gets fewer and fewer, but there is still huge amount of offending code... (the root issue is that if `vector<const T>` occurs in a header file and the header file is used by many `.cc` files, it's difficult to do large-scale changes to remove them at once). So I really appreciate that #80711 worked around the problem.

https://github.com/llvm/llvm-project/pull/80558


More information about the libcxx-commits mailing list