[libcxx-commits] [libcxx] [libc++] Destroy elements when exceptions are thrown in __construct_at_end (PR #167112)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 19 13:57:56 PDT 2026
================
@@ -933,10 +930,7 @@ template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
_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->__alloc_, std::__to_address(__pos), __x);
- }
+ __tx.__pos_ = std::__uninitialized_allocator_fill_n(this->__alloc_, this->__end_, __n, __x);
----------------
ldionne wrote:
I think we could remove the uses of `_ConstructTransaction` pretty easily?
https://github.com/llvm/llvm-project/pull/167112
More information about the libcxx-commits
mailing list