ipaddress 1.1.0
|
An iterator for unified traversal over IPv4 and IPv6 address spaces. More...
#include <ip-any-iterator.hpp>
Public Types | |
using | iterator_category = std::random_access_iterator_tag |
Iterator category. | |
using | value_type = T |
Value type iterated over. | |
using | difference_type = int64_t |
Difference type between iterators. | |
using | pointer = const value_type* |
Pointer to value type. | |
using | reference = const value_type& |
Reference to value type. | |
using | uint_type = uint128_t |
Unsigned integer type for addressing. | |
Public Member Functions | |
constexpr inline | ip_any_iterator () noexcept=default |
Default constructor. | |
constexpr inline | ip_any_iterator (Ipv4Iter iter) noexcept |
Constructs an ip_any_iterator from an Ipv4Iter iterator. | |
constexpr inline | ip_any_iterator (Ipv6Iter iter) noexcept |
Constructs an ip_any_iterator from an Ipv6Iter iterator. | |
constexpr inline uint128_t | uint_diff (const ip_any_iterator &other) const noexcept |
Calculates the difference in the number of elements between this and another ip_any_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 uint128_t &n) const noexcept |
Accesses an element by index. | |
constexpr inline ip_any_iterator & | operator++ () noexcept |
Pre-increment operator. | |
constexpr inline ip_any_iterator | operator++ (int) noexcept |
Post-increment operator. | |
constexpr inline ip_any_iterator & | operator-- () noexcept |
Pre-decrement operator. | |
constexpr inline ip_any_iterator | operator-- (int) noexcept |
Post-decrement operator. | |
constexpr inline ip_any_iterator & | operator+= (difference_type n) noexcept |
Addition assignment operator. | |
constexpr inline ip_any_iterator & | operator+= (const uint128_t &n) noexcept |
Addition assignment operator. | |
constexpr inline ip_any_iterator & | operator-= (difference_type n) noexcept |
Subtraction assignment operator. | |
constexpr inline ip_any_iterator & | operator-= (const uint128_t &n) noexcept |
Subtraction assignment operator. | |
constexpr inline ip_any_iterator | operator+ (difference_type n) const noexcept |
Addition operator. | |
constexpr inline ip_any_iterator | operator+ (const uint128_t &n) const noexcept |
Addition operator. | |
constexpr inline ip_any_iterator | operator- (difference_type n) const noexcept |
Subtraction operator. | |
constexpr inline ip_any_iterator | operator- (const uint128_t &n) const noexcept |
Subtraction operator. | |
constexpr inline difference_type | operator- (const ip_any_iterator &other) const noexcept |
Subtraction operator. | |
constexpr inline bool | operator== (const ip_any_iterator &other) const noexcept |
Equality operator. | |
constexpr inline bool | operator!= (const ip_any_iterator &other) const noexcept |
Inequality operator. | |
constexpr inline bool | operator< (const ip_any_iterator &other) const noexcept |
Less-than operator. | |
constexpr inline bool | operator<= (const ip_any_iterator &other) const noexcept |
Less-than-or-equal-to operator. | |
constexpr inline bool | operator> (const ip_any_iterator &other) const noexcept |
Greater-than operator. | |
constexpr inline bool | operator>= (const ip_any_iterator &other) const noexcept |
Greater-than-or-equal-to operator. | |
An iterator for unified traversal over IPv4 and IPv6 address spaces.
The ip_any_iterator
class template provides a mechanism to iterate over both IPv4 and IPv6 addresses using a single, unified interface. It abstracts the complexities associated with handling the two different IP versions, allowing for code that is agnostic to the IP version it operates on. This is particularly useful for applications that must work with both IPv4 and IPv6 networks, such as dual-stack network configurations, without the need for separate code paths. The iterator supports random access, which enables efficient traversal and manipulation of IP address ranges in various network operations.
T | The type of IP address or network (IPv4 or IPv6) the iterator will handle. |
Ipv4Iter | The type of IPv4 iterator |
Ipv6Iter | The type of IPv6 iterator |
|
inlinenoexcept |
Constructs an ip_any_iterator from an Ipv4Iter iterator.
[in] | iter | The underlying iterator to reverse. |
|
inlinenoexcept |
Constructs an ip_any_iterator from an Ipv6Iter iterator.
[in] | iter | The underlying iterator to reverse. |
|
inlinenoexcept |
Calculates the difference in the number of elements between this and another ip_any_iterator.
[in] | other | The ip_any_iterator to compare with. |
|
inlinenoexcept |
Returns a reference to the current element.
|
inlinenoexcept |
Returns a pointer to the current element.
|
inlinenoexcept |
Accesses an element by index.
[in] | n | The index of the element. |
|
inlinenoexcept |
Accesses an element by index.
[in] | n | The index of the element. |
|
inlinenoexcept |
Pre-increment operator.
|
inlinenoexcept |
Post-increment operator.
|
inlinenoexcept |
Pre-decrement operator.
|
inlinenoexcept |
Post-decrement operator.
|
inlinenoexcept |
Addition assignment operator.
Moves the iterator forward by n positions.
[in] | n | The number of positions to move the iterator forward. |
|
inlinenoexcept |
Addition assignment operator.
Moves the iterator forward by n positions.
[in] | n | The number of positions to move the iterator forward. |
|
inlinenoexcept |
Subtraction assignment operator.
Moves the iterator backward by n positions.
[in] | n | The number of positions to move the iterator backward. |
|
inlinenoexcept |
Subtraction assignment operator.
Moves the iterator backward by n positions.
[in] | n | The number of positions to move the iterator backward. |
|
inlinenoexcept |
Addition operator.
Creates a new iterator that is n positions ahead of the current one.
[in] | n | The number of positions to move ahead. |
|
inlinenoexcept |
Addition operator.
Creates a new iterator that is n positions ahead of the current one.
[in] | n | The number of positions to move ahead. |
|
inlinenoexcept |
Subtraction operator.
Creates a new iterator that is n positions behind the current one.
[in] | n | The number of positions to move behind. |
|
inlinenoexcept |
Subtraction operator.
Creates a new iterator that is n positions behind the current one.
[in] | n | The number of positions to move behind. |
|
inlinenoexcept |
Subtraction operator.
Calculates the difference in the number of elements between this and another ip_any_iterator.
[in] | other | The ip_any_iterator to compare with. |
|
inlinenoexcept |
Equality operator.
Compares two ip_any_iterator for equality.
[in] | other | The ip_any_iterator to compare with. |
true
if the iterators are equal, false
otherwise.
|
inlinenoexcept |
Inequality operator.
Compares two ip_any_iterator for inequality.
[in] | other | The ip_any_iterator to compare with. |
true
if the iterators are not equal, false
otherwise.
|
inlinenoexcept |
Less-than operator.
Compares two ip_any_iterator to determine if the left one is less than the right one.
[in] | other | The ip_any_iterator to compare with. |
true
if the left iterator is less than the right iterator, false
otherwise.
|
inlinenoexcept |
Less-than-or-equal-to operator.
Compares two ip_any_iterator to determine if the left one is less than or equal to the right one.
[in] | other | The ip_any_iterator to compare with. |
true
if the left iterator is less than or equal to the right iterator, false
otherwise.
|
inlinenoexcept |
Greater-than operator.
Compares two ip_any_iterator to determine if the left one is greater than the right one.
[in] | other | The ip_any_iterator to compare with. |
true
if the left iterator is greater than the right iterator, false
otherwise.
|
inlinenoexcept |
Greater-than-or-equal-to operator.
Compares two ip_any_iterator to determine if the left one is greater than or equal to the right one.
[in] | other | The ip_any_iterator to compare with. |
true
if the left iterator is greater than or equal to the right iterator, false
otherwise.