I have a class member variable like this:

vector<vector<int> >  m_stacks;

When I populate it, I do like this:

vector<int> v;
v.push_back(1);
v.push_back(2);
m_stacks.push_back(v);
vector<int> v2;
v2.push_back(1);
v2.push_back(2);
m_stacks.push_back(v2);

Now I am wondering what I should do in the class destructor to release m_stacks. I do not allocate any heap memory for it, so I am struggling if I really need to do anything. Finally I come up this -

vector<vector<int> >::iterator itr = m_stacks.begin();
for ( ; itr != m_stacks.end(); ++itr) {
  itr->clear();
}

I think this is the most I need to do, I do not need to call m_stacks.clear(). The reason is vector's destructor can automatically release the memory. But I still need the above code though, the reason is vector's destructor does not call its element's destructor.

Could you confirm my call?

Edit
Report