I am running clang-tidy
on the code below:
BinaryTree& operator=(const BinaryTree &bt){
if(this == &bt){
return *this;
}
if(_root != nullptr) {
delete _root;
}
_root = new node(nullptr, bt._root->_data);
copy_con(_root, bt._root);
return *this;
}
It gives the following error:
Error: operator=() does not handle self-assignment properly.
This is strange, since my code does handle self-assignment in the first line!
How can I fix this?