boost::openmethod::weak_virtual_ptr::lock
Lock the weak pointer
Description
Return a shared_virtual_ptr to the object, using the remembered v‐table pointer. No hash table lookup is performed.
Example
struct Animal {
virtual ~Animal() = default;
};
struct Dog : Animal {};
struct Cat : Animal {};
BOOST_OPENMETHOD_CLASSES(Animal, Dog, Cat);
shared_virtual_ptr<Animal> animal = make_shared_virtual<Dog>();
weak_virtual_ptr<Animal> observer = animal;
std::cout << poke(observer.lock()) << "\n"; // bark
animal = nullptr;
std::cout << std::boolalpha << observer.expired() << "\n"; // true
Return Value
A shared_virtual_ptr to the object if it still exists, or an empty shared_virtual_ptr with a nullptr v‐table pointer otherwise.
Created with MrDocs