Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/include/__vector/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ class _LIBCPP_TEMPLATE_VIS vector {
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __alloc_(__a) {
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
if (__n > 0) {
__vallocate(__n);
__construct_at_end(__n, __x);
}
__guard.__complete();
}

template <class _InputIterator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ int main(int, char**) {
check_new_delete_called();
#endif // TEST_STD_VER >= 14

try { // Throw in vector(size_type, value_type, const allocator_type&) from the type
int throw_after = 1;
ThrowingT v(throw_after);
std::vector<ThrowingT> vec(1, v, std::allocator<ThrowingT>());
} catch (int) {
}
check_new_delete_called();

try { // Throw in vector(InputIterator, InputIterator) from input iterator
std::vector<int> vec((Iterator<std::input_iterator_tag>()), Iterator<std::input_iterator_tag>(2));
} catch (int) {
Expand Down
Loading