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

Add STL iterator capabilities to surface::RangeIteratorBase<T> and surface::NavigationIteratorBase<T> #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bjude
Copy link

@bjude bjude commented Nov 7, 2022

The main iterators for the halfedge meshes were almost forward iterators, this PR gets them to a usable state. They dont quite meet the LegacyForwardIterator requirements (https://en.cppreference.com/w/cpp/named_req/ForwardIterator) as they generate their elements on dereference, but they do meet the C++20 std::forward_iterator requirements so there shouldnt be any issue using them with STL algorithms (including C++20 ranges)

Closes #76

…requirements

This allows the various set ranges to be used with std algorithms.

These iterators differ from the LegacyForwardIterator requirements (https://en.cppreference.com/w/cpp/named_req/ForwardIterator) in a couple of ways
- No operator->: Since these iterators construct their elements on dereference, theres not safe way to return pointer to one outside of using a proxy object. Operator-> isnt required for c++20's std::input_iterator concept so shouldnt be an issue for std algorithms
- std::iterator_traits<RangeIteratorBase<T>>::reference is not a reference: Similar reasoning to above, it could be defined as `const value_type&` but that could be asking for a dangling reference. This is also not a requirement for c++20's std::forward_iterator
…ator requirements

The `const bool` in `VertexNeighborIteratorState` was causing the default constructor for `NavigationIteratorBase<VertexAdjacentVertexNavigator>` and friends by implicitly deleting default constructors up the chain. This was solved by making the member variables private and adding `const` accessors. The functionality of the class should be the same, just a few renamings to avoid clashes
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.

Standard Iterator Categories for RangeSetBase
1 participant