在 C++ 标准vector.capacity部分,它为 定义了两个重载resize()。(另见https://en.cppreference.com/w/cpp/container/vector/resize)
此重载要求类型 T 是MoveInsertableand DefaultInsertable:
constexpr void resize(size_type sz);
Run Code Online (Sandbox Code Playgroud)
另一个重载要求类型 T 是CopyInsertable:
constexpr void resize(size_type sz, const T& c);
Run Code Online (Sandbox Code Playgroud)
标准中提到的部分的第 16 条规定了第一次重载:
如果非 Cpp17CopyInsertable T的移动构造函数引发异常,则不会产生任何影响。
但是对于第二次重载,它指出:
如果抛出异常,则没有任何影响。
第二个重载中没有提到移动构造函数的抛出。为什么?