@@ -705,8 +705,7 @@ class virtual_ptr {
705705 typename = std::enable_if_t <
706706 BOOST_OPENMETHOD_DETAIL_UNLESS_MRDOCS
707707 IsPolymorphic<Class, Registry> &&
708- std::is_constructible_v<
709- Class*, typename virtual_ptr<Other, Registry>::element_type*>>>
708+ std::is_constructible_v<Class*, Other*>>>
710709 virtual_ptr (Other* other)
711710 : vp(detail::box_vptr<use_indirect_vptrs>(
712711 detail::acquire_vptr<Registry>(*other))),
@@ -1105,7 +1104,13 @@ class virtual_ptr<
11051104 }
11061105
11071106 virtual_ptr (const virtual_ptr& other) = default ;
1108- virtual_ptr (virtual_ptr&& other) = default ;
1107+
1108+ virtual_ptr (virtual_ptr&& other)
1109+ : vp(std::exchange(
1110+ other.vp,
1111+ detail::box_vptr<use_indirect_vptrs>(detail::null_vptr))),
1112+ obj (std::move(other.obj)) {
1113+ }
11091114
11101115 // ! Construct from a (const) smart pointer to a derived class
11111116 // !
@@ -1304,7 +1309,7 @@ class virtual_ptr<
13041309 : vp(other.vp), obj(other.obj) {
13051310 }
13061311
1307- // ! Move from a virtual pointer to a derived class
1312+ // ! Construct-move from a virtual pointer to a derived class
13081313 // !
13091314 // ! Move the object pointer from `other` to `this`. Copy the v-table pointer
13101315 // ! from `other`.
@@ -1341,8 +1346,10 @@ class virtual_ptr<
13411346 SameSmartPtr<SmartPtr, Other, Registry> &&
13421347 std::is_constructible_v<SmartPtr, Other&&>>>
13431348 virtual_ptr (virtual_ptr<Other, Registry>&& other)
1344- : vp(other.vp), obj(std::move(other.obj)) {
1345- other.vp = detail::box_vptr<use_indirect_vptrs>(detail::null_vptr);
1349+ : vp(std::exchange(
1350+ other.vp,
1351+ detail::box_vptr<use_indirect_vptrs>(detail::null_vptr))),
1352+ obj(std::move(other.obj)) {
13461353 }
13471354
13481355 // ! Assign from `nullptr`
@@ -1577,9 +1584,10 @@ class virtual_ptr<
15771584 SameSmartPtr<SmartPtr, Other, Registry> &&
15781585 std::is_assignable_v<SmartPtr, Other&&>>>
15791586 virtual_ptr& operator =(virtual_ptr<Other, Registry>&& other) {
1587+ vp = std::exchange (
1588+ other.vp , detail::box_vptr<use_indirect_vptrs>(detail::null_vptr));
15801589 obj = std::move (other.obj );
1581- vp = other.vp ;
1582- other.vp = detail::box_vptr<use_indirect_vptrs>(detail::null_vptr);
1590+
15831591 return *this ;
15841592 }
15851593
0 commit comments