boost::openmethod::virtual_ptr :: Boost.OpenMethod

# 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_traits` must be specialized for `Class&`.

- `Class` must be a class type, possibly cv‐qualified, registered in `Registry`.

## Types

Name | Description
`element_type` | Class

## Member Functions

Name | Description
`virtual_ptr` [constructor] | Constructors
`operator=` | Assignment operators
`get` | Get a pointer to the object
`operator‐>` | Get a pointer to the object
`operator*` | Get a reference to the object
`pointer` | Get a pointer to the object
`cast` | Cast to another `virtual_ptr` type
`vptr` | Get the v‐table pointer

## Static Member Functions

Name | Description
`final` | Construct a `virtual_ptr` from a reference to an object

## Non-Member Functions

Name | Description
`operator!=` | Compare two `virtual_ptr`s for inequality.
`operator==` | 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 `Class` is registered
unnamed | Implementation defined, use default

Created with MrDocs