In the C++ standard vector.capacity section, it defines two overloads for resize()
. (see also https://en.cppreference.com/w/cpp/container/vector/resize)
This overload requires that the type T is MoveInsertable
and DefaultInsertable
:
constexpr void resize(size_type sz);
The other overload requires that the type T is CopyInsertable
:
constexpr void resize(size_type sz, const T& c);
Clause 16 of the mentioned section in the standard states for the first overload that:
If an exception is thrown other than by the move constructor of a non-Cpp17CopyInsertable T there are no effects.
But for the second overload it states:
If an exception is thrown there are no effects.
Throwing of the move constructor is not mentioned in the second overload. why?
Throwing of the move constructor is not mentioned in the second overload. why?
Because the second overload requires the type to be CopyInsertable. Given that requirement, the case "of a non-Cpp17CopyInsertable T" doesn't exist for the second overload, so there is no need to mention that case.