I am debugging one memory issue it has some relation with the std::list::erase
method.
While reading the documentation for std::list::erase
, I saw this statement:
"This effectively reduces the container size by the number of elements removed, which are destroyed."
I am having difficulty in understanding this statement. As an example, consider this setup:
class demo {
};
std::list<demo *> mylist;
Now, suppose I call mylist.erase(iterator of list)
. I thought that this would call the destructor for class demo
, but it doesn't seem to, which seems to contradict the statement "which are destroyed."
Can you please help me with this?
Thanks!