boost::openmethod::VirtualTraits::vptr
Returns a reference to the v‐table pointer for an object.
Synopsis
Declared in <boost/openmethod/core.hpp>
static
vptr_type const&
vptr(virtual_type const& arg);
Description
vptr is optional. It is called on the object returned by peek, not on the method argument itself. A method acquires the v‐table pointer of a virtual argument from the first of the following that is available: a boost_openmethod_vptr function, found by ADL on the peeked object; vptr; policies::VptrFn::dynamic_vptr of the registry's policies::vptr policy.
Implement vptr only if the v‐table pointer cannot be obtained from the dynamic type of the peeked object, as reported by the registry's policies::rtti policy, or if it is already at hand. The former is the case for any‐like types: their dynamic type is the wrapper, not the value they contain. The std::any specializations read the type_id of the contained value from arg.type(), and pass it to policies::VptrFn::vptr. The latter is the case for a wide type that caches the v‐table pointer: virtual_any returns the one it acquired when it was created, without a lookup.
vptr must return a reference, not a value, so that the caller observes the current v‐table pointer if the registry contains the policies::indirect_vptr policy and initialize is called again.