10 Jul
2006
10 Jul
'06
5:58 a.m.
This question is based on curiosity. How does std::vector::pop_back() call the destructor of the item getting removed? i understood std::vector to be a contigious array of memory, therefore an item's memory does not go out of scope when being popped. ie the item goes out of scope when the entire array goes out of scope. example code: the reference count is decremented when the item is popped from the vector. boost::shared_ptr<int> item1(new int(1)); std::vector< boost::shared_ptr<int> > vect1; vect1.push_back(item1); std::cout << item1.use_count() << std::endl; vect1.pop_back(); std::cout << item1.use_count() << std::endl;