RPNX::DataStructures
Header-only C++ data structures and supporting utilities.
Loading...
Searching...
No Matches
rpnx::bidirectional_bounded_iterator< It > Class Template Reference

Random-access iterator adapter with bidirectional range checks. More...

#include <iterator.hpp>

Public Types

using iterator_type = It
 Wrapped iterator type.
 
using iterator_category = typename traits::iterator_category
 Iterator category exposed by the wrapped iterator.
 
using value_type = typename traits::value_type
 Iterated value type.
 
using difference_type = typename traits::difference_type
 Signed iterator-distance type.
 
using pointer = typename traits::pointer
 Pointer type returned by member access.
 
using reference = typename traits::reference
 Reference type returned by dereference.
 

Public Member Functions

 bidirectional_bounded_iterator ()=default
 Constructs value-initialized current, first, and last iterators.
 
constexpr bidirectional_bounded_iterator (It current, It first, It last)
 Constructs a bounded adapter over an underlying range.
 
constexpr reference operator* () const
 Dereferences the current position.
 
constexpr pointer operator-> () const
 Accesses the current element.
 
constexpr bidirectional_bounded_iteratoroperator++ ()
 Advances one position.
 
constexpr bidirectional_bounded_iterator operator++ (int)
 Advances one position.
 
constexpr bidirectional_bounded_iteratoroperator-- ()
 Retreats one position.
 
constexpr bidirectional_bounded_iterator operator-- (int)
 Retreats one position.
 
constexpr bidirectional_bounded_iteratoroperator+= (difference_type n)
 Moves by an offset with range checking.
 
constexpr bidirectional_bounded_iteratoroperator-= (difference_type n)
 Moves backward by an offset with range checking.
 
constexpr bidirectional_bounded_iterator operator+ (difference_type n) const
 Returns an iterator moved by an offset.
 
constexpr bidirectional_bounded_iterator operator- (difference_type n) const
 Returns an iterator moved backward by an offset.
 
constexpr reference operator[] (difference_type n) const
 Dereferences an offset position.
 
constexpr difference_type operator- (const bidirectional_bounded_iterator &other) const
 Computes the distance from another iterator.
 
constexpr bool operator== (const bidirectional_bounded_iterator &other) const
 Compares positions for equality.
 
constexpr bool operator!= (const bidirectional_bounded_iterator &other) const
 Compares positions for inequality.
 
constexpr bool operator< (const bidirectional_bounded_iterator &other) const
 Tests whether this position precedes another.
 
constexpr bool operator> (const bidirectional_bounded_iterator &other) const
 Tests whether this position follows another.
 
constexpr bool operator<= (const bidirectional_bounded_iterator &other) const
 Tests whether this position does not follow another.
 
constexpr bool operator>= (const bidirectional_bounded_iterator &other) const
 Tests whether this position does not precede another.
 

Friends

constexpr bidirectional_bounded_iterator operator+ (difference_type n, const bidirectional_bounded_iterator &it)
 Returns an iterator moved by an offset.
 

Detailed Description

template<class It>
class rpnx::bidirectional_bounded_iterator< It >

Random-access iterator adapter with bidirectional range checks.

Dereference and movement operations validate the closed position range [first, last], with last retained as a non-dereferenceable end position. All three wrapped iterators must belong to the same range and must outlive this non-owning adapter.

Template Parameters
ItRandom-access iterator type to wrap.

Constructor & Destructor Documentation

◆ bidirectional_bounded_iterator()

template<class It>
rpnx::bidirectional_bounded_iterator< It >::bidirectional_bounded_iterator ( It current,
It first,
It last )
inlineconstexpr

Constructs a bounded adapter over an underlying range.

Parameters
currentCurrent position in [first, last].
firstFirst dereferenceable position.
lastNon-dereferenceable end position.
Precondition
All iterators refer to the same range.

Member Function Documentation

◆ operator!=()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator!= ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Compares positions for inequality.

Parameters
otherIterator to compare.
Returns
true when positions differ.

◆ operator*()

template<class It>
reference rpnx::bidirectional_bounded_iterator< It >::operator* ( ) const
inlineconstexpr

Dereferences the current position.

Returns
Referenced element.
Exceptions
std::out_of_rangeif the current position is outside [first, last).

◆ operator+()

template<class It>
bidirectional_bounded_iterator rpnx::bidirectional_bounded_iterator< It >::operator+ ( difference_type n) const
inlineconstexpr

Returns an iterator moved by an offset.

Parameters
nSigned offset.
Returns
Shifted iterator.
Exceptions
std::out_of_rangeif the result is outside [first, last].

◆ operator++() [1/2]

template<class It>
bidirectional_bounded_iterator & rpnx::bidirectional_bounded_iterator< It >::operator++ ( )
inlineconstexpr

Advances one position.

Returns
Reference to this iterator.
Exceptions
std::out_of_rangeif already at or beyond last.

◆ operator++() [2/2]

template<class It>
bidirectional_bounded_iterator rpnx::bidirectional_bounded_iterator< It >::operator++ ( int )
inlineconstexpr

Advances one position.

Returns
Copy of the iterator before increment.
Exceptions
std::out_of_rangeif already at or beyond last.

◆ operator+=()

template<class It>
bidirectional_bounded_iterator & rpnx::bidirectional_bounded_iterator< It >::operator+= ( difference_type n)
inlineconstexpr

Moves by an offset with range checking.

Parameters
nSigned offset.
Returns
Reference to this iterator.
Exceptions
std::out_of_rangeif the result is outside [first, last].

◆ operator-() [1/2]

template<class It>
difference_type rpnx::bidirectional_bounded_iterator< It >::operator- ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Computes the distance from another iterator.

Parameters
otherIterator in the same range.
Returns
Signed positional difference.

◆ operator-() [2/2]

template<class It>
bidirectional_bounded_iterator rpnx::bidirectional_bounded_iterator< It >::operator- ( difference_type n) const
inlineconstexpr

Returns an iterator moved backward by an offset.

Parameters
nSigned offset.
Returns
Shifted iterator.

◆ operator--() [1/2]

template<class It>
bidirectional_bounded_iterator & rpnx::bidirectional_bounded_iterator< It >::operator-- ( )
inlineconstexpr

Retreats one position.

Returns
Reference to this iterator.
Exceptions
std::out_of_rangeif already at or before first.

◆ operator--() [2/2]

template<class It>
bidirectional_bounded_iterator rpnx::bidirectional_bounded_iterator< It >::operator-- ( int )
inlineconstexpr

Retreats one position.

Returns
Copy of the iterator before decrement.
Exceptions
std::out_of_rangeif already at or before first.

◆ operator-=()

template<class It>
bidirectional_bounded_iterator & rpnx::bidirectional_bounded_iterator< It >::operator-= ( difference_type n)
inlineconstexpr

Moves backward by an offset with range checking.

Parameters
nSigned offset.
Returns
Reference to this iterator.
Exceptions
std::out_of_rangeif the result is outside [first, last].

◆ operator->()

template<class It>
pointer rpnx::bidirectional_bounded_iterator< It >::operator-> ( ) const
inlineconstexpr

Accesses the current element.

Returns
Pointer to the current element.
Exceptions
std::out_of_rangeif the current position is outside [first, last).

◆ operator<()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator< ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Tests whether this position precedes another.

Parameters
otherIterator in the same range.
Returns
Ordering result.

◆ operator<=()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator<= ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Tests whether this position does not follow another.

Parameters
otherIterator in the same range.
Returns
Ordering result.

◆ operator==()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator== ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Compares positions for equality.

Parameters
otherIterator to compare.
Returns
true when positions are equal.

◆ operator>()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator> ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Tests whether this position follows another.

Parameters
otherIterator in the same range.
Returns
Ordering result.

◆ operator>=()

template<class It>
bool rpnx::bidirectional_bounded_iterator< It >::operator>= ( const bidirectional_bounded_iterator< It > & other) const
inlineconstexpr

Tests whether this position does not precede another.

Parameters
otherIterator in the same range.
Returns
Ordering result.

◆ operator[]()

template<class It>
reference rpnx::bidirectional_bounded_iterator< It >::operator[] ( difference_type n) const
inlineconstexpr

Dereferences an offset position.

Parameters
nSigned offset.
Returns
Referenced element.
Exceptions
std::out_of_rangeif the offset position is not dereferenceable.

Friends And Related Symbol Documentation

◆ operator+

template<class It>
bidirectional_bounded_iterator operator+ ( difference_type n,
const bidirectional_bounded_iterator< It > & it )
friend

Returns an iterator moved by an offset.

Parameters
nSigned offset.
itIterator to shift.
Returns
Shifted iterator.

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