boost::openmethod::virtual_ptr::operator=

Assign a virtual_ptr from a reference to an object

Synopsis

Declared in <boost/openmethod/core.hpp>

template<class Other>
requires IsPolymorphic<Class, Registry> &&
            std::is_assignable_v<Class*&, Other*>
virtual_ptr&
operator=(Other& other);

Description

The pointer to the v‐table is obtained by calling boost_openmethod_vptr if a suitable overload exists, or the policies::VptrFn::dynamic_vptr of the registry's vptr policy otherwise.

Example

virtual_ptr<Animal> p{nullptr};
Dog snoopy;
Animal& animal = snoopy;

p = animal;

BOOST_TEST(p.get() == &snoopy);
BOOST_TEST(p.vptr() == default_registry::static_vptr<Dog>);

Requirements

  • Other must be a polymorphic class, according to the rtti policy of Registry.

  • Other* must be constructible from Class*.

Errors

The following errors may occur, depending on the policies selected in Registry:

Parameters

Name

Description

other

A reference to a polymorphic object

Created with MrDocs