Skip to content

Conversation

@anarthal
Copy link
Collaborator

@anarthal anarthal commented Nov 20, 2025

  • Makes flat_tree implementation use a custom buffer. This allows:
    • Never dangling nodes (previously, node values could dangle after calling reserve() or if notify_done() wasn't called).
    • Reduced memory consumption
    • Increased runtime speed
  • Changes flat_tree assignment to the usual signature and semantics
  • Fixes a bug causing an assertion to trigger when copy-constructing an empty flat_tree.
  • Changes basic_node operator== and operator!= return type
  • Adds generic_flat_response, basic_tree, tree, view_tree, flat_tree to the reference page.
  • Adds a missing resp3:: qualifier to all names in the reference page that belong to the resp3 namespace.
  • Adds reference documentation to flat_tree.
  • Mentions generic_flat_response in the discussion.
  • Adds operator!= for basic_node to basic_node's reference page.
  • Adds test_flat_tree.

close #357
close #354
close #352

@anarthal
Copy link
Collaborator Author

@mzimbres I've written a new implementation for flat_tree that should fix the problems I reported. I've used a home-grown buffer like the one I shown in the comparison I did here. The idea is:

  • We have just a view_tree, no offsets.
  • Since we control the buffer, we can hook up to the reallocation process.
  • When a reallocation happens, we compute the offsets by doing pointer arithmetic and update the strings. Strings are guaranteed to be valid at any point (so we have stronger invariants). The only point where doing this arithmetic is not UB is right after the new buffer is allocated and before the old one is deleted.

Before I start writing the tests and docs, could you please have a look and double check if you think this is a good approach?

@anarthal anarthal requested a review from mzimbres November 27, 2025 13:11
@anarthal anarthal merged commit d9e4b2c into boostorg:develop Nov 29, 2025
17 checks passed
@anarthal anarthal deleted the feature/flat-tree-improvements branch November 29, 2025 20:35
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.

Flat tree: reserve generates dangling pointers Flat response: flat_tree copy/move operation problems Flat response: doc reference

2 participants