Skip to content

feat: reverse_iterator support - #1474

Open
sxrzh wants to merge 2 commits into
jbeder:masterfrom
sxrzh:reverse-iterator
Open

feat: reverse_iterator support#1474
sxrzh wants to merge 2 commits into
jbeder:masterfrom
sxrzh:reverse-iterator

Conversation

@sxrzh

@sxrzh sxrzh commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Adds reverse_iterator support for YAML::Node, including:

  • Node::reverse_iterator and Node::const_reverse_iterator
  • Node::rbegin() and Node::rend(), including const versions

I didn't do the same for node_iterator, for I think node iterators won't be used directly and there're no systematic tests for node iterators.

Currently iterator_base and node_iterator_base are incompatible with std::reverse_iterator, since their operator->() function returns a proxy object, which could cause dangling pointer with std::reverse_iterator. So I implemented a customized reverse_iterator_base wrapper in yaml-cpp/node/detail/reverse_iterator.h .

@sxrzh

sxrzh commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

So I implemented a customized reverse_iterator_base wrapper in yaml-cpp/node/detail/reverse_iterator.h .

Note that this does not meet the requirements for ReversibleContainer. Since the current YAML::Node is also far away from Container (maybe it is never intended to be), I think this is acceptable.

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.

1 participant