[libcxx-commits] [libcxx] [libc++] Add __uninitialized_allocator_{fill, value_construct, move} and use them in vector (PR #207500)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 8 08:01:56 PDT 2026


================
@@ -880,10 +880,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const {
 template <class _Tp, class _Allocator>
 _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) {
   _ConstructTransaction __tx(*this, __n);
-  const_pointer __new_end = __tx.__new_end_;
-  for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
-    __alloc_traits::construct(this->__layout_.__alloc(), std::__to_address(__pos));
-  }
+  __tx.__pos_ = std::__uninitialized_allocator_value_construct(__layout_.__alloc(), __tx.__pos_, __tx.__new_end_);
----------------
ldionne wrote:

Can't we get rid of the transaction now?

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


More information about the libcxx-commits mailing list