You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The moveFrom private helper is built in assumption (with corresponding assert!) that this node is un-linked b/c it...
either never been linked - just being constructed (see move ctor)
or, were properly removed first from a tree, and now ready to be reassigned (see move assignment operator)
So, for the case # 2 (operator=(Node&&) there should be also conditional node removal (in case it's linked to a tree), like this:
auto operator=(Node&& other) noexcept -> Node&
{
if (isLinked())
{
remove();
}
moveFrom(other);
return *this;
}
Such fix requires refactoring of Node::remove methods to make them non-static, and not requiring initial origin argument, so that method prototype will be like this:
, and private static removeImpl will be very close to current algorithm with minor changes so that neither initial origin nor root knowledge is required (deduced from context instead).
The text was updated successfully, but these errors were encountered:
Here is current code of the move assignment:
The
moveFrom
private helper is built in assumption (with corresponding assert!) thatthis
node is un-linked b/c it...So, for the case # 2 (
operator=(Node&&
) there should be also conditional node removal (in case it's linked to a tree), like this:Such fix requires refactoring of
Node::remove
methods to make them non-static, and not requiring initialorigin
argument, so that method prototype will be like this:, and private static
removeImpl
will be very close to current algorithm with minor changes so that neither initialorigin
norroot
knowledge is required (deduced from context instead).The text was updated successfully, but these errors were encountered: