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

Make collection iterators fulfill LegacyInputIterator and input_iterator concept #626

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

m-fila
Copy link
Contributor

@m-fila m-fila commented Jun 11, 2024

BEGINRELEASENOTES

  • Added missing operations and type aliases so collection iterators fulfill LegacyInputIterator and std::input_iterator concept

ENDRELEASENOTES

Fixes: #150, fixes #272
Conflicts: #273

Implement missing features so CollectionIterators and MutableCollectionIterators fulfill the requirements imposed on the C++ iterators (#598). It's expected than not all requirements can be fulfilled as some are in direct conflict with podio design:

  • LegacyForwardIterator: dereference should return a reference, but in podio iterators are 'proxy iterators' returning user layer objects as a proxy for reference
  • LegacyForwardItertor: dereferencing two iterators that are equal should give two references bound to the same object, but in podio the returned 'proxies' are different objects
  • std::forward_iterator: pointers and references obtained from an iterator should be valid as range the range is valid, but in podio the iterators behave like 'stashing iterators' -> pointers point to iterator member variable limiting their validity to the lifetime of the iterator.

As a consequence the iterators can the podio iterators can be at most LegacyInputIterator and std::input_iterator. This PR implements missing features to achieve this.

List of changes:

Named requirements:

  • LegacyIterator:
    • copy constructor and assignment
    • type aliases
  • LegacyInputIterator:
    • postfix increment
  • LegacForwardIterator:
    • value-initialization
    • dereference return reference not proxy
    • dereferencing equal iterators returns references to the same object
  • OutputIterator:
    • assignment should modify collection
  • iterator_category is std::input_iterator_tag
  • check selected algorithms operating on LegacyInputIterators

Concepts:

  • semantics checks for concepts
  • std::input_or_output_iterator
    • same as LegacyIterator but copyability not required
  • std::input_iterator
    • std::indirectly_readable and std::readable (can dereference both iterator and const iterator)
  • std::forward_iterator
    • syntax: constrains (except iterator_concept to be derived fromstd::forward_iterator_tag)
    • semantic: pointers obtained from iterator should remain valid as long as range is valid (no-stashing)
  • iterator_concept is std::input_iterator_tag
  • check selected range algorithms constrained to std::input_iterator

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not fully done yet, but I think it would be nice to also document which (classes of) algorithms will be enabled by this (if any).

python/templates/macros/iterator.jinja2 Show resolved Hide resolved
python/templates/macros/iterator.jinja2 Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants