[libcxx-commits] [libcxx] [libc++] Optimize vector growing of trivially relocatable types (PR #76657)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 11 09:59:26 PST 2024
================
@@ -45,6 +47,10 @@ class _LIBCPP_TEMPLATE_VIS allocator;
template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
class _LIBCPP_TEMPLATE_VIS basic_string;
+// TODO: This could be extended to also allow custom allocators and possibly custom chars and char traits
+template <class _CharT>
+struct __libcpp_is_trivially_relocatable<basic_string<_CharT>> : is_fundamental<_CharT> {};
----------------
ldionne wrote:
Here we could instead say:
```
template <class _CharT>
struct __libcpp_is_trivially_relocatable<basic_string<_CharT>> : __is_primary_template<basic_string<_CharT>> {};
```
Since `_CharT` must be trivial, `_CharT` has to be trivially relocatable. The only thing that matters is that we don't take for granted that user-defined specializations of `std::basic_string` are trivially relocatable.
https://github.com/llvm/llvm-project/pull/76657
More information about the libcxx-commits
mailing list