Introduce new class IteratorFacade and add proxy iterator support
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
pointerallows to use the facade classes for proxy-iterators. This was not possible before, because it is not sufficient to simply exchange thereferencetype to support proxies. - The design is in line with the
std::iterator_interfaceproposal, 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_interfaceis parameterized by the iterator concept instead of the category tag. -
srd::iterator_interfaceavoids classic CRTP by deducingthis.
-
The old facade classes are aliases toIteratorFacadewith the appropriate category tag. They also now have an additional template parameter forpointerthat defaults tovalue_type*. Notice that the position of this template parameter is (confusingly, but for good reason) different toIteratorFacade: For the old facade classes it is appended to keep backward compatibility, forIteratorFacadeit follows the order ofstd::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