TRIQS/itertools 1.3.0
C++ range library
Loading...
Searching...
No Matches
itertools::transform_iter< Iter, F, Value >

#include <itertools/transform.hpp>

Detailed Description

template<typename Iter, typename F, typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
struct itertools::transform_iter< Iter, F, Value >

Iterator for a itertools::transformed range.

It stores an iterator of the original range and a callable object that is used to transform the elements of the original range. Incrementing simply increments the iterator. Dereferencing returns the result of the callable object applied to the dereferenced iterator, i.e. the transformed element.

See itertools::transform(R &&, F) for more details.

Template Parameters
IterIterator type.
FCallable type.
ValueReturn type of the callable.

Definition at line 50 of file transform.hpp.

Public Member Functions

 transform_iter ()=default
 Default constructor.
 
 transform_iter (Iter it, F lambda)
 Construct a transformed iterator from a given iterator and callable.
 
 transform_iter (transform_iter &&)=default
 Default move constructor.
 
 transform_iter (transform_iter const &)=default
 Default copy constructor.
 
decltype(auto) dereference () const
 Dereference the iterator.
 
void increment ()
 Increment the iterator by incrementing the original iterator.
 
transform_iteroperator= (transform_iter &&)=default
 Default move assignment operator.
 
transform_iteroperator= (transform_iter const &other)
 Custom copy assignment operator makes sure that the optional callable is correctly copied.
 
template<typename SentinelIter >
bool operator== (sentinel_t< SentinelIter > const &s) const
 Equal-to operator for a itertools::transform_iter and an itertools::sentinel_t.
 
bool operator== (transform_iter const &other) const
 Equal-to operator for two itertools::transform_iter objects.
 

Public Attributes

Iter it
 Iterator of the original range.
 
std::optional< F > lambda
 Callable doing the transformation.
 

Constructor & Destructor Documentation

◆ transform_iter()

template<typename Iter , typename F , typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
itertools::transform_iter< Iter, F, Value >::transform_iter ( Iter it,
F lambda )
inline

Construct a transformed iterator from a given iterator and callable.

Parameters
itIterator of the original range.
lambdaCallable doing the transformation.

Definition at line 66 of file transform.hpp.

Member Function Documentation

◆ dereference()

template<typename Iter , typename F , typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
decltype(auto) itertools::transform_iter< Iter, F, Value >::dereference ( ) const
inlinenodiscard

Dereference the iterator.

Returns
Result of the callable applied to the dereferenced iterator, i.e. the transformed value.

Definition at line 114 of file transform.hpp.

◆ operator=()

template<typename Iter , typename F , typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
transform_iter & itertools::transform_iter< Iter, F, Value >::operator= ( transform_iter< Iter, F, Value > const & other)
inline

Custom copy assignment operator makes sure that the optional callable is correctly copied.

Parameters
otheritertools::transform_iter to copy from.

Definition at line 84 of file transform.hpp.

◆ operator==() [1/2]

template<typename Iter , typename F , typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
template<typename SentinelIter >
bool itertools::transform_iter< Iter, F, Value >::operator== ( sentinel_t< SentinelIter > const & s) const
inlinenodiscard

Equal-to operator for a itertools::transform_iter and an itertools::sentinel_t.

Template Parameters
SentinelIterIterator type of the sentinel.
Parameters
sitertools::sentinel_t to compare with.
Returns
True, if the original iterator is equal to the iterator stored in the sentinel.

Definition at line 108 of file transform.hpp.

◆ operator==() [2/2]

template<typename Iter , typename F , typename Value = std::invoke_result_t<F, typename std::iterator_traits<Iter>::value_type>>
bool itertools::transform_iter< Iter, F, Value >::operator== ( transform_iter< Iter, F, Value > const & other) const
inlinenodiscard

Equal-to operator for two itertools::transform_iter objects.

Parameters
otheritertools::transform_iter to compare with.
Returns
True, if the original iterators are equal.

Definition at line 99 of file transform.hpp.


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