Skip to content
Snippets Groups Projects
Commit 604c7636 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Introduce new class IteratorFacade

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 because
  `srd::iterator_interface` avoids classic CRTP by deducing `this`.
* Additionally to the old facade classes, `IteratorFacade`
  also allows to implement the raw analouges of the
  methods used in the old classes, i.e.
  * `operator*` instead of `dereference()`,
  * `operator++` instead of `increment()`,
  * `operator--` instead of `decrement()`,
  * `operator+=` instead of `advance()`,
  * `operator==` instead of `equals()`,
  * `operator- instead of `distanceTo()`.
* If the implementation class provides a `baseIterator()`
  method returning an underlying internal iterator, the
  operators of the returned iterator will be used if not
  dedicated implementation is provided.

A major consequence of this change is, that it allows to
use the new `IteratorFacade` 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.
parent 51d95bb9
No related branches found
No related tags found
1 merge request!1396Introduce new class IteratorFacade and add proxy iterator support
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment