Skip to content

Introduce new class IteratorFacade and add proxy iterator support

Carsten Gräser requested to merge feature/iterator-facades-proxy-support into master

The new CRTP-mixin class IteratorFacade is parameterized by implementation, iterator category, value_type, reference, pointer, and difference_type. Discussion of the changes:

  • Making the iterator category a template parameter, allows to work with the facades class in a more uniform way. E.g. comparisons only need to be defined once for all categories.
  • Being able to customize pointer allows to use the facade classes for proxy-iterators. This was not possible before, because it is not sufficient to simply exchange the reference type to support proxies.
  • The design is in line with the std::iterator_interface proposal, in the sense that the template parameters have the same order to avoid surprises. Notice however, that this is not a drop-in replacement for two reasons:
    • std::iterator_interface is parameterized by the iterator concept instead of the category tag.
    • srd::iterator_interface avoids classic CRTP by deducing this.
  • The old facade classes are aliases to IteratorFacade with the appropriate category tag. They also now have an additional template parameter for pointer that defaults to value_type*. Notice that the position of this template parameter is (confusingly, but for good reason) different to IteratorFacade: For the old facade classes it is appended to keep backward compatibility, for IteratorFacade it follows the order of std::iterator_interface.
  • The old facade classes remain unchanged for backward compatibility reasons.

A major consequence of this change is, that it allows to use the facades for proxy-iterators, like e.g. TransformedRangeIterator. In this case you have to specify a suitable proxy-type for the pointer. In this case the new helper Dune::ProxyArrowResult can be used. This was adopted from the TransformedRangeIterator, but the name was adjusted to the std::iterator_interface proposal.

This MR also includes some cleanups to TransformedRangeIterator made possible by the new facades and preparing it for supporting free operators.

Edited by Carsten Gräser

Merge request reports

Loading