swift
Loading...
Searching...
No Matches
swift::misc::Iterators::TransformIterator< I, F > Class Template Reference

Iterator wrapper which applies some transformation function to each element. More...

#include <iterator.h>

Public Types

using undecayed_type
 The type returned by the transformation function, which may or may not be a reference.
using pointer
 The type returned by this iterator's arrow operator, which may be a pointer or a pointer-like wrapper object.
using iterator_category = std::forward_iterator_tag
 Types.
using value_type
 Types.
using difference_type = typename std::iterator_traits<I>::difference_type
 Types.
using reference = typename std::iterator_traits<I>::reference
 Types.

Public Member Functions

 TransformIterator (I iterator, F function)
 Constructor.
 TransformIterator (I end)
 Implicit conversion from an end iterator.
undecayed_type operator* ()
 Dereference operator, returns the transformed object reference by the iterator. Undefined if iterator is at the end.
pointer operator-> ()
 Indirection operator, returns a pointer to the transformed object, or a pointer-like wrapper object if the transformation function returns by value. Undefined if iterator is at the end.
TransformIterator & operator++ ()
 Advance to the next element. Undefined if iterator is at the end.
TransformIterator operator++ (int)
 Advance to the next element. Undefined if iterator is at the end.
bool operator== (const TransformIterator &other) const
 Comparison operators.
bool operator!= (const TransformIterator &other) const
 Comparison operators.
bool operator< (const TransformIterator &other) const
 Comparison operators.
bool operator<= (const TransformIterator &other) const
 Comparison operators.
bool operator> (const TransformIterator &other) const
 Comparison operators.
bool operator>= (const TransformIterator &other) const
 Comparison operators.

Detailed Description

template<class I, class F>
class swift::misc::Iterators::TransformIterator< I, F >

Iterator wrapper which applies some transformation function to each element.

By creating a CRange from such iterators, it is possible to perform a transformation on a container without copying elements.

Definition at line 107 of file iterator.h.

Member Typedef Documentation

◆ difference_type

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::difference_type = typename std::iterator_traits<I>::difference_type

Types.

Definition at line 115 of file iterator.h.

◆ iterator_category

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::iterator_category = std::forward_iterator_tag

Types.

Definition at line 112 of file iterator.h.

◆ pointer

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::pointer
Initial value:
std::conditional_t<std::is_reference_v<undecayed_type>,
std::remove_reference_t<undecayed_type> *, PointerWrapper>

The type returned by this iterator's arrow operator, which may be a pointer or a pointer-like wrapper object.

Definition at line 137 of file iterator.h.

◆ reference

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::reference = typename std::iterator_traits<I>::reference

Types.

Definition at line 116 of file iterator.h.

◆ undecayed_type

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::undecayed_type
Initial value:
decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()))

The type returned by the transformation function, which may or may not be a reference.

Definition at line 120 of file iterator.h.

◆ value_type

template<class I, class F>
using swift::misc::Iterators::TransformIterator< I, F >::value_type
Initial value:
std::decay_t<decltype(std::declval<F>()(std::declval<typename std::iterator_traits<I>::value_type>()))>

Types.

Definition at line 113 of file iterator.h.

Constructor & Destructor Documentation

◆ TransformIterator() [1/2]

template<class I, class F>
swift::misc::Iterators::TransformIterator< I, F >::TransformIterator ( I iterator,
F function )
inline

Constructor.

Definition at line 141 of file iterator.h.

◆ TransformIterator() [2/2]

template<class I, class F>
swift::misc::Iterators::TransformIterator< I, F >::TransformIterator ( I end)
inline

Implicit conversion from an end iterator.

Definition at line 144 of file iterator.h.

Member Function Documentation

◆ operator!=()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator!= ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 183 of file iterator.h.

◆ operator*()

template<class I, class F>
undecayed_type swift::misc::Iterators::TransformIterator< I, F >::operator* ( )
inline

Dereference operator, returns the transformed object reference by the iterator. Undefined if iterator is at the end.

Definition at line 164 of file iterator.h.

◆ operator++() [1/2]

template<class I, class F>
TransformIterator & swift::misc::Iterators::TransformIterator< I, F >::operator++ ( )
inline

Advance to the next element. Undefined if iterator is at the end.

Definition at line 149 of file iterator.h.

◆ operator++() [2/2]

template<class I, class F>
TransformIterator swift::misc::Iterators::TransformIterator< I, F >::operator++ ( int )
inline

Advance to the next element. Undefined if iterator is at the end.

Definition at line 154 of file iterator.h.

◆ operator->()

template<class I, class F>
pointer swift::misc::Iterators::TransformIterator< I, F >::operator-> ( )
inline

Indirection operator, returns a pointer to the transformed object, or a pointer-like wrapper object if the transformation function returns by value. Undefined if iterator is at the end.

Definition at line 173 of file iterator.h.

◆ operator<()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator< ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 184 of file iterator.h.

◆ operator<=()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator<= ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 185 of file iterator.h.

◆ operator==()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator== ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 182 of file iterator.h.

◆ operator>()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator> ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 186 of file iterator.h.

◆ operator>=()

template<class I, class F>
bool swift::misc::Iterators::TransformIterator< I, F >::operator>= ( const TransformIterator< I, F > & other) const
inline

Comparison operators.

Definition at line 187 of file iterator.h.


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