c++ - Find pointer to derived class in a table after the object was destroyed -
i have derived class derived class base i have std:: container of derived* pointers (such vector, set, etc...). have base* pointer , know if container contains pointer. rtti , dynamic_cast<derived*>(base) not usable @ point, object may have been destroyed, or may in destructor call chain. how can check if container contains base pointer? if static_cast works, possible. cppreference : static_cast . if new_type pointer or reference class d , type of expression pointer or reference non-virtual base b, static_cast performs downcast. such static_cast makes no runtime checks ensure object's runtime type d, , may used safely if precondition guaranteed other means, such when implementing static polymorphism. safe downcast may done dynamic_cast. there no checks, static_cast should make correct pointer adjustment. reinterpret_cast relies on &base == &derived static_cast allows compiler return adjustment base if derived class not @ start of ...