Dune Core Modules (2.7.1)

Dune::TransformedRangeView< R, F > Class Template Reference

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, F >
 Const iterator type. More...
 
using iterator = Impl::TransformedRangeIterator< RawIterator, F >
 Iterator type. More...
 
using RawRange = std::remove_reference_t< R >
 Export type of the wrapped untransformed range. More...
 

Public Member Functions

template<class RR >
constexpr TransformedRangeView (RR &&rawRange, const F &f) noexcept
 Construct from range and function.
 
constexpr const_iterator begin () const noexcept
 Obtain a iterator to the first element. More...
 
constexpr const_iterator end () const noexcept
 Obtain a iterator past the last element. More...
 
template<class Dummy = R, class = void_t<decltype(std::declval<Dummy>().size())>>
auto size () const
 Obtain the size of the range. More...
 
const RawRangerawRange () const
 Export the wrapped untransformed range.
 
RawRangerawRange ()
 Export the wrapped untransformed range.
 

Detailed Description

template<class R, class F>
class Dune::TransformedRangeView< R, F >

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 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 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
RUnderlying range.
FUnary function used to transform the values in the underlying range.

Member Typedef Documentation

◆ const_iterator

template<class R , class F >
using Dune::TransformedRangeView< R, F >::const_iterator = Impl::TransformedRangeIterator<RawConstIterator, F>

Const iterator type.

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

◆ iterator

template<class R , class F >
using Dune::TransformedRangeView< R, F >::iterator = Impl::TransformedRangeIterator<RawIterator, F>

Iterator type.

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

◆ RawRange

template<class R , class F >
using Dune::TransformedRangeView< R, F >::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.

Member Function Documentation

◆ begin()

template<class R , class F >
constexpr const_iterator Dune::TransformedRangeView< R, F >::begin ( ) const
inlineconstexprnoexcept

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.

◆ end()

template<class R , class F >
constexpr const_iterator Dune::TransformedRangeView< R, F >::end ( ) const
inlineconstexprnoexcept

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.

◆ size()

template<class R , class F >
template<class Dummy = R, class = void_t<decltype(std::declval<Dummy>().size())>>
auto Dune::TransformedRangeView< R, F >::size ( ) const
inline

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:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)