**I have an object that many pointers point to. They often try to access the data. However at some point this object might be destroyed. How do I efficiently update those pointers as soon as I destroy the object so they won't point to unallocated memory and cause undefined behaviour?**

My Idea was making a list of pointers that need to be updated to `nullptr`. This would be called in the destructor of the object. Ugly mess and a lot of work for every single thing that might be deallocated.

Maybe there is some use in those smart pointers for cases like these (never used them). How do C++ programmers handle stuff like that?