I want to keep the smart behavior of std::shared_ptr
. So is there a way to cast a shared void pointer to another type while without confusing the reference counting? I can't get the raw pointer and create a new shared pointer from it.
You can use std::static_pointer_cast
or std::dynamic_pointer_cast
depending on what kind of cast you want.