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 > |
using | value_type = typename iterator::value_type |
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 |
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.
R | Underlying range. |
F | Unary function used to transform the values in the underlying range. |
using const_iterator = Impl::MappedRangeIterator<RawConstIterator, F> |
Iterator type.
This inherits the iterator_category of the iterators of the underlying range.
|
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.
|
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.
|
inlineconstexprnoexcept |
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()
.