c++ - should I erase by myself the pointer of an boost::ptr_vector? -
i wondering if code leak :
int main()
{
boost::ptr_vector <char
> v;
v.push_back(new char[10]);
v.clear()
}
will ptr_vector destructor or clear() function delete pointers contains or have myself?
from vector documentation (http://www.cplusplus.com/reference/stl/vector/~vector/):
vector destructor
destructs container object. calls each of contained element's destructors, , deallocates storage capacity allocated vector.
delete[] won't called, it'll leak. , other commenters pointed out, there more stl ways it.
Comments
Post a Comment