JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::EnumerateIterator< Iter, Index > Class Template Reference

An iterator that wraps some other iterator, keeping track of the relative position of that iterator based on calls to arithmetic operators such as operator++(), operator--(), operator+(), and operator-(). More...

#include <juce_Enumerate.h>

Collaboration diagram for juce::EnumerateIterator< Iter, Index >:

Public Member Functions

constexpr EnumerateIterator ()=default
 Default constructor.
 
constexpr EnumerateIterator (Iter iter)
 Wraps the provided iterator, and sets the internal count to 0.
 
constexpr EnumerateIterator (Iter iter, Index ind)
 Wraps the provided iterator, and sets the internal count to the provided value.
 
template<typename OtherIter , typename OtherInd >
constexpr bool operator!= (const EnumerateIterator< OtherIter, OtherInd > &other) const
 
constexpr Enumerated< Index, decltype(*std::declval< Iter >())> operator* () const
 Dereferencing the iterator produces an Enumerated instance by value.
 
constexpr EnumerateIteratoroperator++ ()
 Increments the iterator and the index.
 
constexpr EnumerateIterator operator++ (int)
 Increments the iterator and the index.
 
template<typename I , std::enable_if_t< detail::canAddAssign< Iter &, I >, int > = 0>
constexpr EnumerateIteratoroperator+= (I diff)
 Adds an integral value to both the iterator and the index.
 
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canSub< Iter, OtherIter >, int > = 0>
constexpr auto operator- (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Subtracts another enumerate iterator from this one, producing the same result as subtracting the two wrapped iterators.
 
template<typename T = Iter, std::enable_if_t< detail::canPreDecrement< T >, int > = 0>
constexpr EnumerateIteratoroperator-- ()
 Decrements the iterator and the index.
 
template<typename T = Iter, std::enable_if_t< detail::canPreDecrement< T >, int > = 0>
constexpr EnumerateIterator operator-- (int)
 Decrements the iterator and the index.
 
template<typename I , std::enable_if_t< detail::canSubAssign< Iter &, I >, int > = 0>
constexpr EnumerateIteratoroperator-= (I diff)
 Subtracts an integral value from both the iterator and the index.
 
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canLessThan< Iter, OtherIter >, int > = 0>
constexpr bool operator< (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Returns the result of comparing the two wrapped iterators.
 
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canLessThanEqual< Iter, OtherIter >, int > = 0>
constexpr bool operator<= (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Returns the result of comparing the two wrapped iterators.
 
template<typename OtherIter , typename OtherInd >
constexpr bool operator== (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Two EnumerateIterators are considered equal if the wrapped iterators are equal.
 
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canGreaterThan< Iter, OtherIter >, int > = 0>
constexpr bool operator> (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Returns the result of comparing the two wrapped iterators.
 
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canGreaterThanEqual< Iter, OtherIter >, int > = 0>
constexpr bool operator>= (const EnumerateIterator< OtherIter, OtherInd > &other) const
 Returns the result of comparing the two wrapped iterators.
 
template<typename I , std::enable_if_t< detail::canAdd< EnumerateIterator, I >, int > = 0>
constexpr auto operator[] (I diff) const
 Indexes into this iterator, equivalent to adding an integral value to this iterator and then dereferencing the result.
 

Private Attributes

Index index = 0
 
Iter iterator {}
 

Friends

template<typename I , std::enable_if_t< detail::canAddAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator+ (EnumerateIterator iter, I ind)
 Returns the result of adding an integral value to this iterator.
 
template<typename I , std::enable_if_t< detail::canAddAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator+ (I ind, EnumerateIterator iter)
 Returns the result of adding an integral value to this iterator.
 
template<typename I , std::enable_if_t< detail::canSubAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator- (EnumerateIterator iter, I ind)
 Returns the result of subtracting an integral value from this iterator.
 

Detailed Description

template<typename Iter, typename Index = ptrdiff_t>
class juce::EnumerateIterator< Iter, Index >

An iterator that wraps some other iterator, keeping track of the relative position of that iterator based on calls to arithmetic operators such as operator++(), operator--(), operator+(), and operator-().

You should never need to construct an instance of this type yourself. Instead, use the enumerate() function to construct a range that can be enumerated.

See also
enumerate() @tags{Core}

Constructor & Destructor Documentation

◆ EnumerateIterator() [1/3]

template<typename Iter , typename Index = ptrdiff_t>
constexpr juce::EnumerateIterator< Iter, Index >::EnumerateIterator ( )
constexprdefault

Default constructor.

◆ EnumerateIterator() [2/3]

template<typename Iter , typename Index = ptrdiff_t>
constexpr juce::EnumerateIterator< Iter, Index >::EnumerateIterator ( Iter  iter)
inlineexplicitconstexpr

Wraps the provided iterator, and sets the internal count to 0.

◆ EnumerateIterator() [3/3]

template<typename Iter , typename Index = ptrdiff_t>
constexpr juce::EnumerateIterator< Iter, Index >::EnumerateIterator ( Iter  iter,
Index  ind 
)
inlineconstexpr

Wraps the provided iterator, and sets the internal count to the provided value.

Member Function Documentation

◆ operator!=()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd >
constexpr bool juce::EnumerateIterator< Iter, Index >::operator!= ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

◆ operator*()

template<typename Iter , typename Index = ptrdiff_t>
constexpr Enumerated< Index, decltype(*std::declval< Iter >())> juce::EnumerateIterator< Iter, Index >::operator* ( ) const
inlineconstexpr

Dereferencing the iterator produces an Enumerated instance by value.

This type holds a copy of the iterator's current index, along with the result of dereferencing the wrapped iterator (normally a reference type).

References juce::EnumerateIterator< Iter, Index >::index, and juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator++() [1/2]

template<typename Iter , typename Index = ptrdiff_t>
constexpr EnumerateIterator & juce::EnumerateIterator< Iter, Index >::operator++ ( )
inlineconstexpr

◆ operator++() [2/2]

template<typename Iter , typename Index = ptrdiff_t>
constexpr EnumerateIterator juce::EnumerateIterator< Iter, Index >::operator++ ( int  )
inlineconstexpr

Increments the iterator and the index.

References juce::EnumerateIterator< Iter, Index >::operator++().

◆ operator+=()

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canAddAssign< Iter &, I >, int > = 0>
constexpr EnumerateIterator & juce::EnumerateIterator< Iter, Index >::operator+= ( diff)
inlineconstexpr

Adds an integral value to both the iterator and the index.

Only participates in overload resolution if the iterator can be add-assigned.

References juce::EnumerateIterator< Iter, Index >::index, and juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator-()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canSub< Iter, OtherIter >, int > = 0>
constexpr auto juce::EnumerateIterator< Iter, Index >::operator- ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Subtracts another enumerate iterator from this one, producing the same result as subtracting the two wrapped iterators.

For random-access iterators, this will normally return the distance between the two iterators. Only participates in overload resolution if the wrapped iterators can be subtracted.

References juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator--() [1/2]

template<typename Iter , typename Index = ptrdiff_t>
template<typename T = Iter, std::enable_if_t< detail::canPreDecrement< T >, int > = 0>
constexpr EnumerateIterator & juce::EnumerateIterator< Iter, Index >::operator-- ( )
inlineconstexpr

Decrements the iterator and the index.

Only participates in overload resolution if the iterator can be pre-decremented.

References juce::EnumerateIterator< Iter, Index >::index, and juce::EnumerateIterator< Iter, Index >::iterator.

Referenced by juce::EnumerateIterator< Iter, Index >::operator--().

◆ operator--() [2/2]

template<typename Iter , typename Index = ptrdiff_t>
template<typename T = Iter, std::enable_if_t< detail::canPreDecrement< T >, int > = 0>
constexpr EnumerateIterator juce::EnumerateIterator< Iter, Index >::operator-- ( int  )
inlineconstexpr

Decrements the iterator and the index.

Only participates in overload resolution if the iterator can be pre-decremented.

References juce::EnumerateIterator< Iter, Index >::operator--().

◆ operator-=()

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canSubAssign< Iter &, I >, int > = 0>
constexpr EnumerateIterator & juce::EnumerateIterator< Iter, Index >::operator-= ( diff)
inlineconstexpr

Subtracts an integral value from both the iterator and the index.

Only participates in overload resolution if the iterator can be sub-assigned.

References juce::EnumerateIterator< Iter, Index >::index, and juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator<()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canLessThan< Iter, OtherIter >, int > = 0>
constexpr bool juce::EnumerateIterator< Iter, Index >::operator< ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Returns the result of comparing the two wrapped iterators.

Only participates in overload resolution if the wrapped iterators are comparable.

References juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator<=()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canLessThanEqual< Iter, OtherIter >, int > = 0>
constexpr bool juce::EnumerateIterator< Iter, Index >::operator<= ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Returns the result of comparing the two wrapped iterators.

Only participates in overload resolution if the wrapped iterators are comparable.

References juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator==()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd >
constexpr bool juce::EnumerateIterator< Iter, Index >::operator== ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Two EnumerateIterators are considered equal if the wrapped iterators are equal.

References juce::EnumerateIterator< Iter, Index >::iterator.

Referenced by juce::EnumerateIterator< Iter, Index >::operator!=().

◆ operator>()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canGreaterThan< Iter, OtherIter >, int > = 0>
constexpr bool juce::EnumerateIterator< Iter, Index >::operator> ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Returns the result of comparing the two wrapped iterators.

Only participates in overload resolution if the wrapped iterators are comparable.

References juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator>=()

template<typename Iter , typename Index = ptrdiff_t>
template<typename OtherIter , typename OtherInd , std::enable_if_t< detail::canGreaterThanEqual< Iter, OtherIter >, int > = 0>
constexpr bool juce::EnumerateIterator< Iter, Index >::operator>= ( const EnumerateIterator< OtherIter, OtherInd > &  other) const
inlineconstexpr

Returns the result of comparing the two wrapped iterators.

Only participates in overload resolution if the wrapped iterators are comparable.

References juce::EnumerateIterator< Iter, Index >::iterator.

◆ operator[]()

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canAdd< EnumerateIterator, I >, int > = 0>
constexpr auto juce::EnumerateIterator< Iter, Index >::operator[] ( diff) const
inlineconstexpr

Indexes into this iterator, equivalent to adding an integral value to this iterator and then dereferencing the result.

Only participates in overload resolution if the wrapped iterator allows addition of integral values.

Friends And Related Symbol Documentation

◆ operator+ [1/2]

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canAddAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator+ ( EnumerateIterator< Iter, Index >  iter,
ind 
)
friend

Returns the result of adding an integral value to this iterator.

Only participates in overload resolution if addition is supported by the wrapped iterator.

◆ operator+ [2/2]

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canAddAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator+ ( ind,
EnumerateIterator< Iter, Index >  iter 
)
friend

Returns the result of adding an integral value to this iterator.

Only participates in overload resolution if addition is supported by the wrapped iterator.

◆ operator-

template<typename Iter , typename Index = ptrdiff_t>
template<typename I , std::enable_if_t< detail::canSubAssign< EnumerateIterator &, I >, int > = 0>
constexpr friend auto operator- ( EnumerateIterator< Iter, Index >  iter,
ind 
)
friend

Returns the result of subtracting an integral value from this iterator.

Only participates in overload resolution if subtraction is supported by the wrapped iterator.

Member Data Documentation

◆ index

◆ iterator


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