ipaddress 1.1.0
Loading...
Searching...
No Matches
ip_reverse_iterator< Iterator > Class Template Reference

A reverse iterator template class for IP addresses. More...

#include <ip-address-iterator.hpp>

Public Types

using iterator_category = typename std::iterator_traits<Iterator>::iterator_category
 The category of the iterator.
 
using iterator_type = Iterator
 The underlying iterator type.
 
using value_type = typename std::iterator_traits<Iterator>::value_type
 The type of the values iterated over.
 
using difference_type = typename std::iterator_traits<Iterator>::difference_type
 The type representing the difference between two iterators.
 
using pointer = typename std::iterator_traits<Iterator>::pointer
 The pointer type of the iterated values.
 
using reference = typename std::iterator_traits<Iterator>::reference
 The reference type of the iterated values.
 
using uint_type = typename Iterator::uint_type
 The unsigned integer type used by the iterator.
 

Public Member Functions

constexpr inline ip_reverse_iterator () noexcept=default
 Default constructor.
 
constexpr inline ip_reverse_iterator (Iterator it) noexcept
 Constructs an ip_reverse_iterator from an underlying iterator.
 
constexpr inline uint_type uint_diff (const ip_reverse_iterator &other) const noexcept
 Calculates the difference in the number of elements between this and another ip_reverse_iterator.
 
constexpr inline iterator_type base () const noexcept
 Returns the underlying base iterator.
 
constexpr inline reference operator* () const noexcept
 Returns a reference to the current element.
 
constexpr inline pointer operator-> () const noexcept
 Returns a pointer to the current element.
 
constexpr inline value_type operator[] (difference_type n) const noexcept
 Accesses an element by index.
 
constexpr inline value_type operator[] (const uint_type &n) const noexcept
 Accesses an element by index.
 
constexpr inline ip_reverse_iteratoroperator++ () noexcept
 Pre-increment operator.
 
constexpr inline ip_reverse_iterator operator++ (int) noexcept
 Post-increment operator.
 
constexpr inline ip_reverse_iteratoroperator-- () noexcept
 Pre-decrement operator.
 
constexpr inline ip_reverse_iterator operator-- (int) noexcept
 Post-decrement operator.
 
constexpr inline ip_reverse_iteratoroperator+= (difference_type n) noexcept
 Addition assignment operator.
 
constexpr inline ip_reverse_iteratoroperator+= (const uint_type &n) noexcept
 Addition assignment operator.
 
constexpr inline ip_reverse_iteratoroperator-= (difference_type n) noexcept
 Subtraction assignment operator.
 
constexpr inline ip_reverse_iteratoroperator-= (const uint_type &n) noexcept
 Subtraction assignment operator.
 
constexpr inline ip_reverse_iterator operator+ (difference_type n) const noexcept
 Addition operator.
 
constexpr inline ip_reverse_iterator operator+ (const uint_type &n) const noexcept
 Addition operator.
 
constexpr inline ip_reverse_iterator operator- (difference_type n) const noexcept
 Subtraction operator.
 
constexpr inline ip_reverse_iterator operator- (const uint_type &n) const noexcept
 Subtraction operator.
 
constexpr inline difference_type operator- (const ip_reverse_iterator &other) const noexcept
 Subtraction operator.
 
constexpr inline bool operator== (const ip_reverse_iterator &other) const noexcept
 Equality operator.
 
constexpr inline bool operator!= (const ip_reverse_iterator &other) const noexcept
 Inequality operator.
 
constexpr inline bool operator< (const ip_reverse_iterator &other) const noexcept
 Less-than operator.
 
constexpr inline bool operator<= (const ip_reverse_iterator &other) const noexcept
 Less-than-or-equal-to operator.
 
constexpr inline bool operator> (const ip_reverse_iterator &other) const noexcept
 Greater-than operator.
 
constexpr inline bool operator>= (const ip_reverse_iterator &other) const noexcept
 Greater-than-or-equal-to operator.
 

Detailed Description

template<typename Iterator>
class ipaddress::ip_reverse_iterator< Iterator >

A reverse iterator template class for IP addresses.

The ip_reverse_iterator class template provides reverse iteration capabilities over a range of IP addresses. It is designed to work with both IPv4 and IPv6 addresses, allowing for backward traversal of IP address sequences. This class template is particularly useful in scenarios where IP addresses need to be processed in reverse order, such as deallocating IP addresses in a network. The ip_reverse_iterator leverages underlying iterator functionality to provide a robust and flexible mechanism for reverse IP address iteration.

Template Parameters
IteratorThe underlying iterator type over which this reverse iterator operates.

Constructor & Destructor Documentation

◆ ip_reverse_iterator() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator ( )
defaultnoexcept

Default constructor.

Constructs an ip_reverse_iterator that points to no object.

◆ ip_reverse_iterator() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator ( Iterator it)
inlineexplicitnoexcept

Constructs an ip_reverse_iterator from an underlying iterator.

Creates an ip_reverse_iterator that is the reverse of the given iterator.

Parameters
[in]itThe underlying iterator to reverse.

Member Function Documentation

◆ uint_diff()

template<typename Iterator >
constexpr inline uint_type uint_diff ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Calculates the difference in the number of elements between this and another ip_reverse_iterator.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
The number of elements between this and the other iterator.
Remarks
This is a special function for calculate the difference between iterators, which can correctly represent all addresses using the integer number uint128_t

◆ base()

template<typename Iterator >
constexpr inline iterator_type base ( ) const
inlinenoexcept

Returns the underlying base iterator.

Returns
The base iterator.

◆ operator*()

template<typename Iterator >
constexpr inline reference operator* ( ) const
inlinenoexcept

Returns a reference to the current element.

Returns
A reference to the element pointed to by the iterator.

◆ operator->()

template<typename Iterator >
constexpr inline pointer operator-> ( ) const
inlinenoexcept

Returns a pointer to the current element.

Returns
A pointer to the element pointed to by the iterator.

◆ operator[]() [1/2]

template<typename Iterator >
constexpr inline value_type operator[] ( difference_type n) const
inlinenoexcept

Accesses an element by index.

Parameters
[in]nThe index of the element.
Returns
The element at the specified index.

◆ operator[]() [2/2]

template<typename Iterator >
constexpr inline value_type operator[] ( const uint_type & n) const
inlinenoexcept

Accesses an element by index.

Parameters
[in]nThe index of the element.
Returns
The element at the specified index.

◆ operator++() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator++ ( )
inlinenoexcept

Pre-increment operator.

Returns
A reference to the incremented iterator.

◆ operator++() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator++ ( int )
inlinenoexcept

Post-increment operator.

Returns
The iterator before incrementing.

◆ operator--() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator-- ( )
inlinenoexcept

Pre-decrement operator.

Returns
A reference to the decremented iterator.

◆ operator--() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator-- ( int )
inlinenoexcept

Post-decrement operator.

Returns
The iterator before decrementing.

◆ operator+=() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator+= ( difference_type n)
inlinenoexcept

Addition assignment operator.

Moves the iterator forward by n positions.

Parameters
[in]nThe number of positions to move the iterator forward.
Returns
A reference to the updated iterator.

◆ operator+=() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator+= ( const uint_type & n)
inlinenoexcept

Addition assignment operator.

Moves the iterator forward by n positions.

Parameters
[in]nThe number of positions to move the iterator forward.
Returns
A reference to the updated iterator.

◆ operator-=() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator-= ( difference_type n)
inlinenoexcept

Subtraction assignment operator.

Moves the iterator backward by n positions.

Parameters
[in]nThe number of positions to move the iterator backward.
Returns
A reference to the updated iterator.

◆ operator-=() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator & operator-= ( const uint_type & n)
inlinenoexcept

Subtraction assignment operator.

Moves the iterator backward by n positions.

Parameters
[in]nThe number of positions to move the iterator backward.
Returns
A reference to the updated iterator.

◆ operator+() [1/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator+ ( difference_type n) const
inlinenoexcept

Addition operator.

Creates a new iterator that is n positions ahead of the current one.

Parameters
[in]nThe number of positions to move ahead.
Returns
A new iterator that is n positions ahead.

◆ operator+() [2/2]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator+ ( const uint_type & n) const
inlinenoexcept

Addition operator.

Creates a new iterator that is n positions ahead of the current one.

Parameters
[in]nThe number of positions to move ahead.
Returns
A new iterator that is n positions ahead.

◆ operator-() [1/3]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator- ( difference_type n) const
inlinenoexcept

Subtraction operator.

Creates a new iterator that is n positions behind the current one.

Parameters
[in]nThe number of positions to move behind.
Returns
A new iterator that is n positions behind.

◆ operator-() [2/3]

template<typename Iterator >
constexpr inline ip_reverse_iterator operator- ( const uint_type & n) const
inlinenoexcept

Subtraction operator.

Creates a new iterator that is n positions behind the current one.

Parameters
[in]nThe number of positions to move behind.
Returns
A new iterator that is n positions behind.

◆ operator-() [3/3]

template<typename Iterator >
constexpr inline difference_type operator- ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Subtraction operator.

Calculates the difference in the number of elements between this and another ip_reverse_iterator.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
The number of elements between this and the other iterator.

◆ operator==()

template<typename Iterator >
constexpr inline bool operator== ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Equality operator.

Compares two ip_reverse_iterators for equality.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the iterators are equal, false otherwise.

◆ operator!=()

template<typename Iterator >
constexpr inline bool operator!= ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Inequality operator.

Compares two ip_reverse_iterators for inequality.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the iterators are not equal, false otherwise.

◆ operator<()

template<typename Iterator >
constexpr inline bool operator< ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Less-than operator.

Compares two ip_reverse_iterators to determine if the left one is less than the right one.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the left iterator is less than the right iterator, false otherwise.

◆ operator<=()

template<typename Iterator >
constexpr inline bool operator<= ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Less-than-or-equal-to operator.

Compares two ip_reverse_iterators to determine if the left one is less than or equal to the right one.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the left iterator is less than or equal to the right iterator, false otherwise.

◆ operator>()

template<typename Iterator >
constexpr inline bool operator> ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Greater-than operator.

Compares two ip_reverse_iterators to determine if the left one is greater than the right one.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the left iterator is greater than the right iterator, false otherwise.

◆ operator>=()

template<typename Iterator >
constexpr inline bool operator>= ( const ip_reverse_iterator< Iterator > & other) const
inlinenoexcept

Greater-than-or-equal-to operator.

Compares two ip_reverse_iterators to determine if the left one is greater than or equal to the right one.

Parameters
[in]otherThe ip_reverse_iterator to compare with.
Returns
true if the left iterator is greater than or equal to the right iterator, false otherwise.

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