Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bstree_algorithms<>::swap_nodes #61

Merged
merged 4 commits into from
Jun 20, 2021

Conversation

dmsteck
Copy link

@dmsteck dmsteck commented May 13, 2021

The node swapping code (which is marked experimental) seems to lack special handling for the case when the nodes to be swapped are siblings (i.e., they have the same parent).

In that case, special care needs to be taken when updating the parent node as aliasing occurs in the normal code.

Run the test case from this PR against current develop to see the bug.

Changes in this PR

  • Fix the node swapping code by adding special logic for the sibling case
  • Moved all the parent updating code to the end of the function for clarity
  • Tests

Notes

I've tried to keep everything C++03 and the tests build with g++ -std=c++03 on my setup.

I've also added (C) notices to both files; please let me know if this is in line with contribution guidelines. I'm not religious about them.

@igaztanaga igaztanaga merged commit edb8f9e into boostorg:develop Jun 20, 2021
@igaztanaga
Copy link
Member

Many thanks for the report and the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants