Skip to content

Change meaning of function template in TransformedRangeIterator

So far the template parameter F was interpreted as function and a const F* was stored. With this patch F is directly interpreted as pointer_type and the * is added in the TransformedRangeView.

This allows to use other pointer-like types than const F*. E.g. TransformedRangeView now uses F* for a non-const iterator, such that the transformation calls a non-const operator() for non-const interators. Thus one can use TransformedRangeIterator to create self-contained mutable ranges on the fly, which was not possible before (either mutable with reference capture or self-contained but non-mutable).

A test for the new feature is added. This also contains a handy utility for combined mutable/nonmutable capture which is not directly possible with plain lambdas. Maybe we later want to make this public.

This patch potentially also allows to create self-contained TransformedRangeIterators by passing e.g. an optional (pointer-like but stores a value) as F. However, this should be carefully tested and - if working correctly - be accessible publicly in namespace Dune::.

Merge request reports