boost::openmethod::virtual_ptr<SmartPtr, Registry>::operator=
Assign from a (const) smart 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, const Other&> &&
BOOST_OPENMETHOD_DETAIL_UNLESS_MRDOCS
IsPolymorphic<typename Other::element_type, Registry>
virtual_ptr&
operator=(Other const& other);
Description
Copy the object pointer from other to this. Set the v‐table pointer according to the dynamic type of *other.
Example
virtual_ptr<std::shared_ptr<Dog>> snoopy = make_shared_virtual<Dog>();
virtual_ptr<std::shared_ptr<Dog>> p;
p = snoopy;
BOOST_TEST(p.get() != nullptr);
BOOST_TEST(p.get() == snoopy.get());
BOOST_TEST(p.vptr() == default_registry::static_vptr<Dog>);
BOOST_TEST(snoopy.vptr() == default_registry::static_vptr<Dog>);
Requirements
-
SmartPtrandOthermust be instantiated from the same template ‐ e.g. bothstd::shared_ptror bothstd::unique_ptr. -
Othermust be a smart pointer to a polymorphic class derived fromelement_type. -
SmartPtrmust be constructible fromconst Other&.
Created with MrDocs