For a project i have to store several objects on a list<myType*>
I was just wondering if the member function list.pop_front will just remove my objects for the list, or totally destroy my object.
Will the member function list.pop_front eventually gonna call the destructor of my object ?
pop_front will remove and destroy the myType pointer. It does nothing to the object that the pointer points so if you want to delete it you will have to do it yourself.
If your compiler supports it, you can use smart pointers like std::unique_ptr so they can be automatically cleaned up when they exit the list.
1 2 3 4 5 6 7 8
typedef std::unique_ptr<int> intptr;
std::list<intptr> mylist;
mylist.push_back( intptr( newint(5) ) );
mylist.pop_back(); // delete is automatically called on the object. You do not have
// to do it manually