[libcxx-commits] [libcxx] [libc++] Optimize vector growth for nothrow move constructible types (PR #214690)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 12 07:45:06 PDT 2026
================
@@ -402,32 +404,46 @@ template <class _Alloc, class _ContiguousIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocator_relocate(
_Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {
static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, "");
- using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type;
static_assert(
__is_cpp17_move_insertable_v<_Alloc>, "The specified type does not meet the requirements of Cpp17MoveInsertable");
- if (__libcpp_is_constant_evaluated() || !__is_trivially_relocatable_v<_ValueType> ||
- !__allocator_has_trivial_move_construct_v<_Alloc, _ValueType> ||
- !__allocator_has_trivial_destroy_v<_Alloc, _ValueType>) {
+
+ using __value_type = typename iterator_traits<_ContiguousIterator>::value_type;
----------------
ldionne wrote:
I'm not super happy with making this function more complex, instead I'd rather reimplement public API operations in terms of simpler building blocks like `__uninitialized_relocate` without a strong exception safety guarantee (and use different building blocks when the types are potentially throwing), but I think this is correct and it should be an optimization, so I'm fine with the patch.
https://github.com/llvm/llvm-project/pull/214690
More information about the libcxx-commits
mailing list