AMDiS  0.1 The Adaptive Multi-Dimensional Simulation Toolbox
MappedRangeView< R, F > Class Template Reference

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

#include <MappedRangeView.hpp>

Public Types

using const_iterator = Impl::MappedRangeIterator< RawConstIterator, F >
Iterator type. More...

using iterator = Impl::MappedRangeIterator< RawIterator, F >

Public Member Functions

template<class RR >
constexpr MappedRangeView (RR &&rawRange, F const &f) noexcept
Construct from range and function.

constexpr const_iterator begin () const noexcept
Obtain a iterator to the first element. More...

constexpr iterator begin () noexcept

template<class RR = R, class = decltype(std::declval<RR>().size())>
constexpr auto size () const noexcept
Return the number of elements in the range, if availble. More...

template<class RR = R, class = decltype(std::declval<RR>().operator[](std::size_t(0)))>
decltype(auto) operator[] (std::size_t i) const
Provide element access for random-accessible ranges.

constexpr bool empty () const noexcept
Checks whether the range is empty.

constexpr const_iterator end () const noexcept
Obtain a iterator past the last element. More...

constexpr iterator end () noexcept

Detailed Description

template<class R, class F> class AMDiS::MappedRangeView< 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 MappedRangeView have the same iterator_category as the ones of the wrapped container.

If range is given as r-value, then the returned MappedRangeView stores it by value, if range is given as (const) l-value, then the MappedRangeView stores it by (const) reference.

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

Template Parameters
 R Underlying range. F Unary function used to transform the values in the underlying range.

◆ const_iterator

 using const_iterator = Impl::MappedRangeIterator

Iterator type.

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

◆ begin()

 constexpr const_iterator begin ( ) const
inlinenoexcept

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()

 constexpr const_iterator end ( ) const
inlinenoexcept

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()

 constexpr auto size ( ) const
inlinenoexcept

Return the number of elements in the range, if availble.

Note, this function is only availble if the underlying raw range knows its size and provides a function size().

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