Good question about how to use c++ smart pointers posted on Stack Overflow. I haven’t used std::weak_ptr, but the idea of using it to return an “observing” pointer that you can later check for expiry and obtain a std::shared_ptr sounds like a better approach that returning a raw pointer.