Skip to content

Add a TransformedRangeView class

Carsten Gräser requested to merge feature/add-transformedrangeview into master

This adds a TransformedRangeView and a helper function transformedRangeView() creating it.

This behaves like a range providing begin() and end(). The iterators over this range internally iterate over the wrapped range. When dereferencing the iterator, the value is transformed on-the-fly using a given transformation function leaving the underlying range unchanged.

The transformation may either return temorary values or l-value references. In the former case the range behaves like a proxy-container. In the latter case it forwards these references allowing, e.g., to sort a subset of some container by applying a transformation to an index-range for those values.

The iterators of the TransformedRangeView have the same iterator_category as the ones of the wrapped container.

If the wrapped range is an r-value, then the TransformedRangeView stores it by value, if the wrapped range is an l-value, then the TransformedRangeView stores it by reference.

Merge request reports

Loading