-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!
Description
template <class _Moveit>
_Nodeptr _Copy_nodes(_Nodeptr _Rootnode, _Nodeptr _Wherenode, _Moveit _Movefl) {
// copy entire subtree, recursively
const auto _Scary = _Get_scary();
_Nodeptr _Newroot = _Scary->_Myhead; // point at nil node
if (!_Rootnode->_Isnil) { // copy or move a node, then any subtrees
bool_constant<is_same_v<key_type, value_type>> _Is_set;
_Nodeptr _Pnode = _Copy_or_move(_Rootnode->_Myval, _Movefl, _Is_set);
_Pnode->_Parent = _Wherenode;
_Pnode->_Color = _Rootnode->_Color;
if (_Newroot->_Isnil) {
_Newroot = _Pnode; // memorize new root
}
_TRY_BEGIN
_Pnode->_Left = _Copy_nodes(_Rootnode->_Left, _Pnode, _Movefl);
_Pnode->_Right = _Copy_nodes(_Rootnode->_Right, _Pnode, _Movefl);
_CATCH_ALL
_Scary->_Erase_tree_and_orphan(_Getal(), _Newroot); // subtree copy failed, bail out
_RERAISE;
_CATCH_END
}
return _Newroot; // return newly constructed tree
}
In function _Copy_nodes which is applied to copy a tree, _Newroot->_Isnil is always true, but here:
if (_Newroot->_Isnil) {
_Newroot = _Pnode; // memorize new root
}
why still determine if it is nil?
Metadata
Metadata
Assignees
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!