mercredi 13 juin 2018

Exception guarantee for vector multiple objects constructor

When calling this vector constructor:

explicit vector( size_type count,
                 const T& value = T(),
                 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.

Aucun commentaire:

Enregistrer un commentaire