向量多对象构造函数的异常保证

时间:2018-06-13 16:05:01

标签: c++11 vector

调用此向量构造函数时:

vector( size_type count,
         const T& value,
         const Allocator& alloc = Allocator());

如果抛出异常并且某些T对象已经构造但不是全部,那么构造的元素总是会被析构函数调用吗?

 std::vector<std::vector<T>> internalBuffer = 
     std::vector<std::vector<T>>(1024, std::vector<T>(1024, 0));

我假设默认分配器和c ++ 11。

1 个答案:

答案 0 :(得分:1)

注意:该特定构造函数已从C ++ 11中删除。

除此之外,你是正确的,在这种情况下将调用所有已构造对象的析构函数。