Skip to content

Commit

Permalink
self-assignment real fix
Browse files Browse the repository at this point in the history
  • Loading branch information
achabense committed Aug 15, 2023
1 parent 03fba39 commit da3f334
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,12 @@ public:

// Assignment [any.assign]
any& operator=(const any& _That) {
*this = any{_That};
_Reset_and_move_from(_That);
return *this;
}

any& operator=(any&& _That) noexcept {
if (this != &_That) {
reset();
_Move_from(_That);
}
_Reset_and_move_from(_STD move(_That));
return *this;
}

Expand Down Expand Up @@ -292,6 +289,11 @@ private:
}
}

void _Reset_and_move_from(any _That) noexcept {
reset();
_Move_from(_That);
}

template <class _Decayed, class... _Types>
_Decayed& _Emplace(_Types&&... _Args) { // emplace construct _Decayed
if constexpr (_Any_is_trivial<_Decayed>) {
Expand Down

0 comments on commit da3f334

Please sign in to comment.