Search code examples
c++stdlist

Can we stop a std::list from tidying up memory?


I defined this list:

using SpecialEventList = list<SPECIAL_EVENT_S*>;

The items are added to this list like this:

m_listNewSpecialEvents.push_back(psEvent);

The original list of SPECIAL_EVENT_S pointers is owned and managed by another list help in the app class.

My concern is that when this dialog closes that m_listNewSpecialEvents will automatically delete the pointers and I don' want it to.

Can we stop this list from tidying up the memory?


Solution

  • It won't delete pointers unless you explicitly delete them. raw pointers don't get deleted automatically. link