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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -