yorel::yomm2::policy::vptr_vector
defined in <yorel/yomm2/policy.hpp>, also provided by <yorel/yomm2/core.hpp>, <yorel/yomm2/keywords.hpp>
template<class Policy>
struct vptr_vector : virtual external_vptr { ... };
vptr_vector
is an implementation of [external_vptr](/yomm2/reference/policy-vptr_placement.html) that stores the
pointers to the v-tables in a
std::vector. If the policy contains a
[
type_hash](/yomm2/reference/policy-type_hash.html) facet, it is used to convert the [
type_id](/yomm2/reference/type_id.html) to an index in the
vector; otherwise, the
type_id` is used as the index.
The default policy uses std_rtti
, fast_perfect_hash
and
vptr_vector
to implement efficient method dispatch. Calling a method with a
single virtual parameter takes only ~33% more time than calling a native virtual
function call.
Policy - the policy containing the facet.
dynamic_vptr | return the address of the v-table for an object |
publish_vptrs | store the vptrs, initialize type_hash if present |
template<class Policy>
template<class Class>
const std::uintptr_t* vptr_vector<Policy>::dynamic_vptr(const Class& object);
Return a pointer to the v-table for object
.
Call Policy::dynamic_type
for object
. If Policy
contains a type_hash
facet, use it to convert the resulting type_id
to an index; otherwise, use the
type_id
as the index.
template<class Policy>
template<typename ForwardIterator>
void vptr_vector<Policy>::publish_vptrs(ForwardIterator first, ForwardIterator last);
If Policy
contains a type_hash
facet, call its hash_initialize
function.
Store the pointers to the v-tables in a vector, indexed by the (possibly hashed)
type_id
s.