boost::openmethod::virtual_ptr<SmartPtr, Registry>::operator= :: Boost.OpenMethod

# boost::openmethod::virtual_ptr<SmartPtr, Registry>::operator=

Move from a virtual pointer to a derived class

## Synopsis

Declared in `<boost/openmethod/core.hpp>`

    template<class Other>
    requires SameSmartPtr<SmartPtr, Other, Registry> &&
                std::is_assignable_v<SmartPtr, Other&&>
    virtual_ptr&
    operator=(virtual_ptr<Other, Registry>&& other);

## Description

Move the object pointer from `other` to `this`. Copy the v‐table pointer from `other`.

`Other` is not required to be a pointer to a polymorphic class.

## Example

    struct Animal {}; // polymorphism not required
    struct Dog : Animal {}; // polymorphism not required
    BOOST_OPENMETHOD_CLASSES(Animal, Dog);
    initialize();

    virtual_ptr<std::shared_ptr<Dog>> snoopy =
        make_shared_virtual<Dog>();
    Dog* moving = snoopy.get();
    virtual_ptr<std::shared_ptr<Dog>> p;

    p = std::move(snoopy);

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

## Requirements

- `SmartPtr` and `Other` must be instantiated from the same template ‐ e.g. both `std::shared_ptr` or both `std::unique_ptr`.

- `Other` must be a smart pointer to a class derived from `element_type`.

- `SmartPtr` must be constructible from `Other&&`.

Created with MrDocs