kblib 0.2.3
General utilities library for modern C++
kblib::transform_iterator< base_iterator, operation > Class Template Reference

An InputIterator that applies a transformation to the elements of the range. More...

#include <kblib/iterators.h>

Public Types

using difference_type = std::ptrdiff_t
 
using result_type = decltype(kblib::invoke(op, *it))
 
using const_result_type = decltype(kblib::invoke(std::as_const(op), *std::as_const(it)))
 
using value_type = result_type
 
using pointer = void
 
using reference = value_type
 
using iterator_category = std::input_iterator_tag
 

Public Member Functions

 transform_iterator (base_iterator _it, operation _op) noexcept(noexcept(base_iterator{ _it}) and noexcept(std::is_nothrow_move_constructible< operation >::value))
 Constructs a transform_iterator which applies _op to the values obtained from *_it. More...
 
 transform_iterator (base_iterator end_it) noexcept(noexcept(base_iterator{ end_it}))
 constructs a non-dereferenceable sentinel iterator More...
 
auto operator* () noexcept(noexcept(kblib::invoke(op, *it))) -> decltype(auto)
 Transforms the value obtained by dereferencing it. More...
 
decltype(auto) operator* () const noexcept(noexcept(kblib::invoke(op, *it)))
 Transforms the value obtained by dereferencing it. More...
 
auto operator-> () noexcept(noexcept(kblib::invoke(op, *it))) -> auto
 Returns a containing_ptr with the transformed value, because operator-> expects a pointer-like return type. More...
 
auto operator-> () const noexcept(noexcept(kblib::invoke(op, *it))) -> auto
 Returns a containing_ptr with the transformed value, because operator-> expects a pointer-like return type. More...
 
auto operator++ () noexcept(noexcept(++it)) -> transform_iterator &
 Increments the underlying iterator and returns *this. More...
 
auto operator++ (int) noexcept(noexcept(transform_iterator{it++, op})) -> transform_iterator
 Increments the underlying iterator and returns a copy of the current value. More...
 
auto base () const noexcept -> base_iterator
 
auto from_base (base_iterator it_) const noexcept(std::is_nothrow_copy_constructible_v< operation >) -> transform_iterator
 

Friends

auto operator== (const transform_iterator &lhs, const transform_iterator &rhs) noexcept -> bool
 Compares the base iterators of lhs and rhs. More...
 
auto operator!= (const transform_iterator &lhs, const transform_iterator &rhs) noexcept -> bool
 Compares the base iterators of lhs and rhs. More...
 
template<typename OIt >
auto operator== (const transform_iterator &lhs, const OIt &rhs) noexcept -> bool
 
template<typename OIt >
auto operator== (const OIt &lhs, const transform_iterator &rhs) noexcept -> bool
 
template<typename OIt >
auto operator!= (const transform_iterator &lhs, const OIt &rhs) noexcept -> bool
 
template<typename OIt >
auto operator!= (const OIt &lhs, const transform_iterator &rhs) noexcept -> bool
 

Detailed Description

template<typename base_iterator, typename operation>
class kblib::transform_iterator< base_iterator, operation >

An InputIterator that applies a transformation to the elements of the range.

Attention
This class template depends on features introduced in C++17.

Definition at line 1149 of file iterators.h.

Member Typedef Documentation

◆ const_result_type

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::const_result_type = decltype(kblib::invoke(std::as_const(op), *std::as_const(it)))

Definition at line 1157 of file iterators.h.

◆ difference_type

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::difference_type = std::ptrdiff_t

Definition at line 1155 of file iterators.h.

◆ iterator_category

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::iterator_category = std::input_iterator_tag

Definition at line 1162 of file iterators.h.

◆ pointer

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::pointer = void

Definition at line 1160 of file iterators.h.

◆ reference

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::reference = value_type

Definition at line 1161 of file iterators.h.

◆ result_type

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::result_type = decltype(kblib::invoke(op, *it))

Definition at line 1156 of file iterators.h.

◆ value_type

template<typename base_iterator , typename operation >
using kblib::transform_iterator< base_iterator, operation >::value_type = result_type

Definition at line 1159 of file iterators.h.

Constructor & Destructor Documentation

◆ transform_iterator() [1/2]

template<typename base_iterator , typename operation >
kblib::transform_iterator< base_iterator, operation >::transform_iterator ( base_iterator  _it,
operation  _op 
)
inlinenoexcept

Constructs a transform_iterator which applies _op to the values obtained from *_it.

Parameters
_itAn InputIterator to a range to be transformed.
_opThe operation to apply to each element.

Definition at line 1171 of file iterators.h.

◆ transform_iterator() [2/2]

template<typename base_iterator , typename operation >
kblib::transform_iterator< base_iterator, operation >::transform_iterator ( base_iterator  end_it)
inlinenoexcept

constructs a non-dereferenceable sentinel iterator

Parameters
end_itAn iterator that marks the end of the input range.

Definition at line 1182 of file iterators.h.

Member Function Documentation

◆ base()

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::base ( ) const -> base_iterator
inlinenoexcept

Definition at line 1238 of file iterators.h.

◆ from_base()

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::from_base ( base_iterator  it_) const -> transform_iterator
inlinenoexcept

Definition at line 1240 of file iterators.h.

◆ operator*() [1/2]

template<typename base_iterator , typename operation >
decltype(auto) kblib::transform_iterator< base_iterator, operation >::operator* ( ) const
inlinenoexcept

Transforms the value obtained by dereferencing it.

Returns
decltype(auto) The result of invoking op on *it.

Definition at line 1201 of file iterators.h.

◆ operator*() [2/2]

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::operator* ( ) -> decltype(auto)
inlinenoexcept

Transforms the value obtained by dereferencing it.

Returns
decltype(auto) The result of invoking op on *it.

Definition at line 1192 of file iterators.h.

◆ operator++() [1/2]

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::operator++ ( ) -> transform_iterator&
inlinenoexcept

Increments the underlying iterator and returns *this.

Definition at line 1223 of file iterators.h.

◆ operator++() [2/2]

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::operator++ ( int  ) -> transform_iterator
inlinenoexcept

Increments the underlying iterator and returns a copy of the current value.

Definition at line 1233 of file iterators.h.

◆ operator->() [1/2]

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::operator-> ( ) const -> auto
inlinenoexcept

Returns a containing_ptr with the transformed value, because operator-> expects a pointer-like return type.

Definition at line 1216 of file iterators.h.

◆ operator->() [2/2]

template<typename base_iterator , typename operation >
auto kblib::transform_iterator< base_iterator, operation >::operator-> ( ) -> auto
inlinenoexcept

Returns a containing_ptr with the transformed value, because operator-> expects a pointer-like return type.

Definition at line 1209 of file iterators.h.

Friends And Related Function Documentation

◆ operator!= [1/3]

template<typename base_iterator , typename operation >
template<typename OIt >
auto operator!= ( const OIt &  lhs,
const transform_iterator< base_iterator, operation > &  rhs 
) -> bool
friend

Definition at line 1279 of file iterators.h.

◆ operator!= [2/3]

template<typename base_iterator , typename operation >
template<typename OIt >
auto operator!= ( const transform_iterator< base_iterator, operation > &  lhs,
const OIt &  rhs 
) -> bool
friend

Definition at line 1274 of file iterators.h.

◆ operator!= [3/3]

template<typename base_iterator , typename operation >
auto operator!= ( const transform_iterator< base_iterator, operation > &  lhs,
const transform_iterator< base_iterator, operation > &  rhs 
) -> bool
friend

Compares the base iterators of lhs and rhs.

Definition at line 1257 of file iterators.h.

◆ operator== [1/3]

template<typename base_iterator , typename operation >
template<typename OIt >
auto operator== ( const OIt &  lhs,
const transform_iterator< base_iterator, operation > &  rhs 
) -> bool
friend

Definition at line 1268 of file iterators.h.

◆ operator== [2/3]

template<typename base_iterator , typename operation >
template<typename OIt >
auto operator== ( const transform_iterator< base_iterator, operation > &  lhs,
const OIt &  rhs 
) -> bool
friend

Definition at line 1263 of file iterators.h.

◆ operator== [3/3]

template<typename base_iterator , typename operation >
auto operator== ( const transform_iterator< base_iterator, operation > &  lhs,
const transform_iterator< base_iterator, operation > &  rhs 
) -> bool
friend

Compares the base iterators of lhs and rhs.

Definition at line 1249 of file iterators.h.


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