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 registry the object's class has an affinity for ‐ see registry_affinity
-
as the
Registrytemplate 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