[libcxx-commits] [libcxx] [libc++] Document how __tree is layed out and how we iterate through it (PR #152453)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 11 12:52:31 PDT 2025
================
@@ -183,6 +204,11 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
return __x->__parent_unsafe();
}
+// __tree_next_iter and __tree_prev_iter implement iteration through the tree. The order is as follows:
+// left sub-tree -> node -> right sub-tree. When the right-most node of a sub-tree is reached, we walk up the tree until
+// we find a node where we were in the left sub-tree. We are _always_ in a left sub-tree, since the __end_node_ points
+// to the actual root of the tree through a __left_ pointer. incrementing the end() pointer is UB, so we can assume that
----------------
ldionne wrote:
```suggestion
// to the actual root of the tree through a __left_ pointer. Incrementing the end() pointer is UB, so we can assume that
```
https://github.com/llvm/llvm-project/pull/152453
More information about the libcxx-commits
mailing list