boost::openmethod::final_virtual_ptr

Create a virtual_ptr for an object of a known exact class.

Synopsis

Declared in <boost/openmethod/core.hpp>

template<class Arg>
auto
final_virtual_ptr(Arg&& obj);

Description

This is an overload of final_virtual_ptr that uses the default registry as the Registry template parameter.

Example

// classes not required to be polymorphic
struct Animal {};
struct Cat : Animal {};
struct Dog : Animal {};

BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);

Dog snoopy;
virtual_ptr<Animal> animal = final_virtual_ptr(snoopy);
std::cout << poke(animal) << "\n"; // bark

Cat felix;
animal = final_virtual_ptr(felix);
std::cout << poke(animal) << "\n"; // hiss

See Also

Created with MrDocs