Skip to content

Commit 7ff58b5

Browse files
committed
[libc++][vector] Make constructor vector(count, value, allocator) exception-safe
1 parent 831ba95 commit 7ff58b5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libcxx/include/vector

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,12 @@ public:
433433
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
434434
vector(size_type __n, const value_type& __x, const allocator_type& __a)
435435
: __end_cap_(nullptr, __a) {
436+
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
436437
if (__n > 0) {
437438
__vallocate(__n);
438439
__construct_at_end(__n, __x);
439440
}
441+
__guard.__complete();
440442
}
441443

442444
template <class _InputIterator,

0 commit comments

Comments
 (0)