Loading...
Searching...
No Matches
Dune::TransformedRangeView< R, F, T > Class Template Reference
Common » Utilities » Range Utilities

A range transforming the values of another range on-the-fly. More...

`#include <dune/common/rangeutilities.hh>`

## Public Types

using | const_iterator = Impl::TransformedRangeIterator<RawConstIterator, const F*, T>
| Const iterator type.
using | iterator = Impl::TransformedRangeIterator<RawIterator, F*, T>
| Iterator type.
using | RawRange = std::remove_reference_t<R>
| Export type of the wrapped untransformed range.

## Public Member Functions

template<class RR, class FF>
constexpr | TransformedRangeView (RR &&rawRange, FF &&f) noexcept
| Construct from range and function.
constexpr const_iterator | begin () const noexcept
| Obtain a iterator to the first element.
constexpr iterator | begin () noexcept
constexpr const_iterator | end () const noexcept
| Obtain a iterator past the last element.
constexpr iterator | end () noexcept
template<class It = const_iterator, std::enable_if_t< std::is_same_v< typename It::iterator_category, std::random_access_iterator_tag >, int > = 0>
constexpr decltype(auto) | operator[] (std::size_t i) const noexcept
| Provide const element access for random-accessible ranges.
template<class It = iterator, std::enable_if_t< std::is_same_v< typename It::iterator_category, std::random_access_iterator_tag >, int > = 0>
constexpr decltype(auto) | operator[] (std::size_t i) noexcept
| Provide mutable element access for random-accessible ranges.
template<class Range = R, class = std::void_t<decltype(std::declval<const Range>().size())>>
auto | size () const noexcept
| Obtain the size of the range.
constexpr bool | empty () const noexcept
| Checks whether the range is empty.
const RawRange & | rawRange () const noexcept
| Export the wrapped untransformed range.
RawRange & | rawRange () noexcept
| Export the wrapped untransformed range.

## Detailed Description

template<class R, class F, class T = ValueTransformationTag>
class Dune::TransformedRangeView< R, F, T >

A range transforming the values of another range on-the-fly.

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 temporary 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 range is given as r-value, then the returned TransformedRangeView stores it by value, if range is given as (const) l-value, then the TransformedRangeView stores it by (const) reference.

If R is a value type, then the TransformedRangeView stores the wrapped range by value, if R is a reference type, then the TransformedRangeView stores the wrapped range by reference.

Template Parameters

  R | Underlying range.
  F | Unary function used to transform the values in the underlying range.
  T | Class for describing how to apply the transformation

T has to be either ValueTransformationTag (default) or IteratorTransformationTag. In the former case, the transformation is applied to the values obtained by dereferencing the wrapped iterator. In the latter case it is applied to the iterator directly, allowing to access non-standard functions of the iterator.

## Member Typedef Documentation

## const_iterator

template<class R, class F, class T = ValueTransformationTag>

using Dune::TransformedRangeView< R, F, T >::const_iterator = Impl::TransformedRangeIterator<RawConstIterator, const F*, T>

Const iterator type.

This inherits the iterator_category of the iterators of the underlying range.

## iterator

template<class R, class F, class T = ValueTransformationTag>

using Dune::TransformedRangeView< R, F, T >::iterator = Impl::TransformedRangeIterator<RawIterator, F*, T>

Iterator type.

This inherits the iterator_category of the iterators of the underlying range.

## RawRange

template<class R, class F, class T = ValueTransformationTag>

using Dune::TransformedRangeView< R, F, T >::RawRange = std::remove_reference_t<R>

Export type of the wrapped untransformed range.

Notice that this will always be the raw type with references removed, even if a reference is stored.

## Constructor & Destructor Documentation

## TransformedRangeView()

template<class R, class F, class T = ValueTransformationTag>
template<class RR, class FF>

Dune::TransformedRangeView< R, F, T >::TransformedRangeView | ( | RR && | rawRange,
|  | FF && | f )

inline constexpr noexcept

Construct from range and function.

## Member Function Documentation

## begin() [1/2]

template<class R, class F, class T = ValueTransformationTag>

const_iterator Dune::TransformedRangeView< R, F, T >::begin | ( |  | ) | const

inline constexpr noexcept

Obtain a iterator to the first element.

The life time of the returned iterator is bound to the life time of the range since it only contains a pointer to the transformation function stored in the range.

## begin() [2/2]

template<class R, class F, class T = ValueTransformationTag>

iterator Dune::TransformedRangeView< R, F, T >::begin | ( |  | ) |

inline constexpr noexcept

## empty()

template<class R, class F, class T = ValueTransformationTag>

bool Dune::TransformedRangeView< R, F, T >::empty | ( |  | ) | const

inline constexpr noexcept

Checks whether the range is empty.

## end() [1/2]

template<class R, class F, class T = ValueTransformationTag>

const_iterator Dune::TransformedRangeView< R, F, T >::end | ( |  | ) | const

inline constexpr noexcept

Obtain a iterator past the last element.

The life time of the returned iterator is bound to the life time of the range since it only contains a pointer to the transformation function stored in the range.

## end() [2/2]

template<class R, class F, class T = ValueTransformationTag>

iterator Dune::TransformedRangeView< R, F, T >::end | ( |  | ) |

inline constexpr noexcept

## operator[]() [1/2]

template<class R, class F, class T = ValueTransformationTag>
template<class It = const_iterator, std::enable_if_t< std::is_same_v< typename It::iterator_category, std::random_access_iterator_tag >, int > = 0>

decltype(auto) Dune::TransformedRangeView< R, F, T >::operator[] | ( | std::size_t | i | ) | const

inline constexpr noexcept

Provide const element access for random-accessible ranges.

## operator[]() [2/2]

template<class R, class F, class T = ValueTransformationTag>
template<class It = iterator, std::enable_if_t< std::is_same_v< typename It::iterator_category, std::random_access_iterator_tag >, int > = 0>

decltype(auto) Dune::TransformedRangeView< R, F, T >::operator[] | ( | std::size_t | i | ) |

inline constexpr noexcept

Provide mutable element access for random-accessible ranges.

## rawRange() [1/2]

template<class R, class F, class T = ValueTransformationTag>

const RawRange & Dune::TransformedRangeView< R, F, T >::rawRange | ( |  | ) | const

inline noexcept

Export the wrapped untransformed range.

## rawRange() [2/2]

template<class R, class F, class T = ValueTransformationTag>

RawRange & Dune::TransformedRangeView< R, F, T >::rawRange | ( |  | ) |

inline noexcept

Export the wrapped untransformed range.

## size()

template<class R, class F, class T = ValueTransformationTag>
template<class Range = R, class = std::void_t<decltype(std::declval<const Range>().size())>>

auto Dune::TransformedRangeView< R, F, T >::size | ( |  | ) | const

inline noexcept

Obtain the size of the range.

This is only available if the underlying range provides a size() method. In this case size() just forwards to the underlying range's size() method.

Attention: Don't select the template parameters explicitly. They are only used to implement SFINAE.

The documentation for this class was generated from the following file:

- rangeutilities.hh