Is there a way to prevent a std::set< Object*>.erase(it) function to delete memory?
I only want the Object* to be removed from the set, without freeing memory..
To be specific, I have an object that removes himself from the set and puts itself to another.
And it crashes.
set1.insert(this);
set1.erase(set1.find(this));
set2.insert(this);
Anyone able to reproduce this? thank you!
Your
set<Object*>already doesn’t delete the pointed-to object when you call the erase for the iterator. If it’s crashing in that area it’s for another reason. Likely causes are: