I have a vector of unique_ptr that points to a class called state. When I call pop_back() with a vector, the unique pointer is deleted from memory (I think), but the state object it pointed to is never deleted. Either this, or the unique pointer somehow does not call the destructor when deleting the object that it points to? All I know is that my destructor is not called when my unique pointer is removed from the vector.
This is a vector:
std::vector< std::unique_ptr<State> > mStates;
I tried:
mStates.pop_back();
This removes the unique pointer, and I thought that the unique pointer would delete the state for me and call the state destructor, but this did not happen. BTW I am adding elements using:
mStates.push_back();
source share