Temple
Temple

Reputation: 1631

Exception guarantee for vector multiple objects constructor

When calling this vector constructor:

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

If exception will be thrown and some T objects will be already constructed but not all of them, will constructed elements always gets destructor called?

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

I'm assuming default allocator and c++11.

Upvotes: 0

Views: 23

Answers (1)

Nevin
Nevin

Reputation: 4863

Note: that particular constructor was removed from C++11.

Other than that, you are correct that the destructors of all the already constructed objects will be called in this case.

Upvotes: 1

Related Questions