avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::ArrayIterator< T, U > Struct Template Reference

Wrapped array iterator. More...

#include <avutils.h>

Public Types

using difference_type = std::ptrdiff_t
 Distance type required by the iterator traits.
using value_type = std::remove_reference_t<U>
 Type produced by dereferencing.
using pointer = std::remove_reference_t<T>*
 Pointer type of the underlying array.
using reference = typename ReferenceSelector<T, U, !UseProxy>::Type
 Dereference result: a proxy wrapper or a plain reference.
using iterator_category
 Iterator category: random access for proxies, contiguous otherwise.

Public Member Functions

 ArrayIterator (pointer ptr) noexcept
 Point the iterator at an array element.
reference operator* () const noexcept
 Element at the current position.
ArrayIterator & operator++ () noexcept
 Advance to the next element.
ArrayIterator operator++ (int) noexcept
 Advance, returning the previous position.
ArrayIterator & operator-- () noexcept
 Step back to the previous element.
ArrayIterator operator-- (int) noexcept
 Step back, returning the previous position.
ArrayIterator & operator+= (int n) noexcept
 Advance by several elements.
ArrayIterator & operator-= (int n) noexcept
 Step back by several elements.
reference operator[] (int n) noexcept
 Element at an offset from the current position.
const reference operator[] (int n) const noexcept
 Element at an offset, read-only.

Static Public Attributes

static constexpr bool UseProxy = !std::is_same_v<std::remove_cvref_t<T>, std::remove_cvref_t<U>>
 Whether dereferencing must produce a proxy view instead of a reference.

Friends

ArrayIterator operator+ (const ArrayIterator &a, int n) noexcept
 Advance an iterator.
ArrayIterator operator+ (int n, const ArrayIterator &a) noexcept
 Advance an iterator.
ArrayIterator operator- (const ArrayIterator &a, int n) noexcept
 Step an iterator back.
difference_type operator- (const ArrayIterator &b, const ArrayIterator &a) noexcept
 Distance between two iterators.
std::strong_ordering operator<=> (const ArrayIterator &a, const ArrayIterator &b) noexcept
 Order two iterators.
bool operator== (const ArrayIterator &a, const ArrayIterator &b)
 Compare two iterators.
bool operator!= (const ArrayIterator &a, const ArrayIterator &b)
 Compare two iterators.
bool operator== (ArrayIterator it, std::default_sentinel_t)=delete
template<class Policy>
constexpr bool operator== (ArrayIterator it, const ArraySentinel< T, Policy > &sentinel)
 Compare an iterator with a sentinel.
template<class Policy>
constexpr bool operator!= (ArrayIterator it, const ArraySentinel< T, Policy > &sentinel)
 Compare an iterator with a sentinel.
template<class Policy>
constexpr bool operator== (const ArraySentinel< T, Policy > &sentinel, ArrayIterator it)
 Compare a sentinel with an iterator.
template<class Policy>
constexpr bool operator!= (const ArraySentinel< T, Policy > &sentinel, ArrayIterator it)
 Compare a sentinel with an iterator.

Detailed Description

template<typename T, typename U>
struct av::ArrayIterator< T, U >

Represents any element of the T* array as light-weight wrapper U

Member Typedef Documentation

◆ iterator_category

template<typename T, typename U>
using av::ArrayIterator< T, U >::iterator_category
Initial value:
std::conditional_t<
std::random_access_iterator_tag,
std::contiguous_iterator_tag>
static constexpr bool UseProxy
Whether dereferencing must produce a proxy view instead of a reference.
Definition avutils.h:615

Constructor & Destructor Documentation

◆ ArrayIterator()

template<typename T, typename U>
av::ArrayIterator< T, U >::ArrayIterator ( pointer ptr)
inlinenoexcept
Parameters
ptrposition in the array

Member Function Documentation

◆ operator*()

template<typename T, typename U>
reference av::ArrayIterator< T, U >::operator* ( ) const
inlinenoexcept
Returns
a wrapped view or a reference, depending on the proxy mode

◆ operator++() [1/2]

template<typename T, typename U>
ArrayIterator & av::ArrayIterator< T, U >::operator++ ( )
inlinenoexcept
Returns
this iterator

◆ operator++() [2/2]

template<typename T, typename U>
ArrayIterator av::ArrayIterator< T, U >::operator++ ( int )
inlinenoexcept
Returns
a copy of the iterator before advancing

◆ operator+=()

template<typename T, typename U>
ArrayIterator & av::ArrayIterator< T, U >::operator+= ( int n)
inlinenoexcept
Parameters
nnumber of elements to skip; may be negative
Returns
this iterator

◆ operator--() [1/2]

template<typename T, typename U>
ArrayIterator & av::ArrayIterator< T, U >::operator-- ( )
inlinenoexcept
Returns
this iterator

◆ operator--() [2/2]

template<typename T, typename U>
ArrayIterator av::ArrayIterator< T, U >::operator-- ( int )
inlinenoexcept
Returns
a copy of the iterator before stepping back

◆ operator-=()

template<typename T, typename U>
ArrayIterator & av::ArrayIterator< T, U >::operator-= ( int n)
inlinenoexcept
Parameters
nnumber of elements to go back; may be negative
Returns
this iterator

◆ operator[]() [1/2]

template<typename T, typename U>
const reference av::ArrayIterator< T, U >::operator[] ( int n) const
inlinenoexcept
Parameters
noffset in elements
Returns
the element, wrapped or referenced

◆ operator[]() [2/2]

template<typename T, typename U>
reference av::ArrayIterator< T, U >::operator[] ( int n)
inlinenoexcept
Parameters
noffset in elements
Returns
the element, wrapped or referenced

◆ operator!= [1/3]

template<typename T, typename U>
template<class Policy>
bool operator!= ( ArrayIterator< T, U > it,
const ArraySentinel< T, Policy > & sentinel )
friend
Parameters
itthe iterator
sentinelthe sentinel
Returns
true while the policy does not report the end

◆ operator!= [2/3]

template<typename T, typename U>
bool operator!= ( const ArrayIterator< T, U > & a,
const ArrayIterator< T, U > & b )
friend
Parameters
athe left iterator
bthe right iterator
Returns
true when they point at different elements

◆ operator!= [3/3]

template<typename T, typename U>
template<class Policy>
bool operator!= ( const ArraySentinel< T, Policy > & sentinel,
ArrayIterator< T, U > it )
friend
Parameters
sentinelthe sentinel
itthe iterator
Returns
true while the policy does not report the end

◆ operator+ [1/2]

template<typename T, typename U>
ArrayIterator operator+ ( const ArrayIterator< T, U > & a,
int n )
friend
Parameters
athe iterator
nnumber of elements to skip
Returns
the advanced iterator

◆ operator+ [2/2]

template<typename T, typename U>
ArrayIterator operator+ ( int n,
const ArrayIterator< T, U > & a )
friend
Parameters
nnumber of elements to skip
athe iterator
Returns
the advanced iterator

◆ operator- [1/2]

template<typename T, typename U>
ArrayIterator operator- ( const ArrayIterator< T, U > & a,
int n )
friend
Parameters
athe iterator
nnumber of elements to go back
Returns
the resulting iterator

◆ operator- [2/2]

template<typename T, typename U>
difference_type operator- ( const ArrayIterator< T, U > & b,
const ArrayIterator< T, U > & a )
friend
Parameters
bthe later iterator
athe earlier iterator
Returns
the difference in elements

◆ operator<=>

template<typename T, typename U>
std::strong_ordering operator<=> ( const ArrayIterator< T, U > & a,
const ArrayIterator< T, U > & b )
friend
Parameters
athe left iterator
bthe right iterator
Returns
the ordering of their positions

◆ operator== [1/3]

template<typename T, typename U>
template<class Policy>
bool operator== ( ArrayIterator< T, U > it,
const ArraySentinel< T, Policy > & sentinel )
friend
Parameters
itthe iterator
sentinelthe sentinel
Returns
true when the policy reports the end of the range

◆ operator== [2/3]

template<typename T, typename U>
bool operator== ( const ArrayIterator< T, U > & a,
const ArrayIterator< T, U > & b )
friend
Parameters
athe left iterator
bthe right iterator
Returns
true when both point at the same element

◆ operator== [3/3]

template<typename T, typename U>
template<class Policy>
bool operator== ( const ArraySentinel< T, Policy > & sentinel,
ArrayIterator< T, U > it )
friend
Parameters
sentinelthe sentinel
itthe iterator
Returns
true when the policy reports the end of the range

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