Commit 40583339 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

This is a workaround for the STL swap function. It has some surprising...

This is a workaround for the STL swap function. It has some surprising behaviour, so I wrote my own.
parent 32eacfb5
...@@ -100,13 +100,22 @@ OptimalIpTree::OptimalIpTree(OptimalIpTree const & right) ...@@ -100,13 +100,22 @@ OptimalIpTree::OptimalIpTree(OptimalIpTree const & right)
} }
} }
template<class T>
void swap_modify(T & left, T & right)
{
T temp;
temp = left;
left = right;
right = temp;
}
OptimalIpTree & OptimalIpTree::operator=(OptimalIpTree const & right) OptimalIpTree & OptimalIpTree::operator=(OptimalIpTree const & right)
{ {
OptimalIpTree swapper(right); OptimalIpTree swapper(right);
m_firstHops.swap(swapper.m_firstHops); m_firstHops.swap(swapper.m_firstHops);
swap(m_depth, swapper.m_depth); swap(m_depth, swapper.m_depth);
swap(m_children[0], swapper.m_children[0]); swap_modify(m_children[0], swapper.m_children[0]);
swap(m_children[1], swapper.m_children[1]); swap_modify(m_children[1], swapper.m_children[1]);
return *this; return *this;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment