boost::openmethod::virtual_ptr
Wide pointer combining pointers to an object and its v‐table
Synopsis
Declared in <boost/openmethod/core.hpp>
template<
class Class,
class Registry = boost::openmethod::default_registry,
typename = /* implementation-defined */>
class virtual_ptr;
Description
A virtual_ptr is a wide pointer that combines pointers to an object and its v‐table. Calls to methods via virtual_ptr are as fast as ordinary virtual function calls (typically two instructions).
A virtual_ptr can be implicitly constructed from a reference, a pointer, or another virtual_ptr, provided that they are type‐compatible.
virtual_ptr has specializations that use a std::shared_ptr or a std::unique_ptr as the pointer to the object. The mechanism can be extended to other smart pointers by specializing virtual_traits. A "plain" virtual_ptr can be constructed from a smart virtual_ptr, but not the other way around.
The default value for Registry can be customized by defining the BOOST_OPENMETHOD_DEFAULT_REGISTRY preprocessor symbol.
Requirements
-
virtual_traitsmust be specialized for `Class&`. -
`Class` must be a class type, possibly cv‐qualified, registered in `Registry`.
Member Functions
Name |
Description |
|
Constructors |
Assignment operators |
|
Get a pointer to the object |
|
Get a pointer to the object |
|
Get a reference to the object |
|
Get a pointer to the object |
|
Cast to another |
|
Get the v‐table pointer |
Static Member Functions
Name |
Description |
Construct a |
Non-Member Functions
Name |
Description |
Compare two `virtual_ptr`s for inequality. |
|
Compare two `virtual_ptr`s for equality. |
Template Parameters
| Name | Description |
|---|---|
Class |
The class of the object, possibly cv‐qualified |
Registry |
The registry in which |
unnamed |
Implementation defined, use default |
Created with MrDocs