ipaddress 1.1.0
Loading...
Searching...
No Matches
subnets_sequence< T > Class Template Reference

A sequence container for subnet ranges within a network. More...

#include <ip-network-iterator.hpp>

Public Types

using value_type = T
 The type of subnet value.
 
using size_type = size_t
 An unsigned integral type.
 
using difference_type = typename value_type::uint_type
 Unsigned integer type for differences.
 
using pointer = value_type*
 Pointer to the subnet type.
 
using const_pointer = const value_type*
 Const pointer to the subnet type.
 
using reference = value_type&
 Reference to the subnet type.
 
using const_reference = const value_type&
 Const reference to the subnet type.
 
using iterator = ip_network_iterator<value_type>
 Forward iterator for subnet traversal.
 
using const_iterator = ip_network_iterator<value_type>
 Const forward iterator for subnet traversal.
 
using reverse_iterator = ip_reverse_iterator<iterator>
 Reverse iterator for subnet traversal.
 
using const_reverse_iterator = ip_reverse_iterator<const_iterator>
 Const reverse iterator for subnet.
 
using ip_address_type = typename value_type::ip_address_type
 The underlying IP address type.
 

Public Member Functions

constexpr inline subnets_sequence () noexcept=default
 Default constructor.
 
constexpr inline subnets_sequence (const ip_address_type &network_address, size_t new_prefixlen) noexcept
 Constructs a sequence of subnets from a single network address with a new prefix length.
 
constexpr inline subnets_sequence (const ip_address_type &network_address, const ip_address_type &broadcast_address, const ip_address_type &hostmask, size_t prefixlen_diff, size_t new_prefixlen) noexcept
 Constructs a sequence of subnets from a network address range with a new prefix length.
 
constexpr inline const_iterator begin () const noexcept
 Gets the beginning iterator of the sequence.
 
constexpr inline const_iterator end () const noexcept
 Gets the end iterator of the sequence.
 
constexpr inline const_reverse_iterator rbegin () const noexcept
 Gets the beginning reverse iterator of the sequence.
 
constexpr inline const_reverse_iterator rend () const noexcept
 Gets the end reverse iterator of the sequence.
 
constexpr inline const_iterator cbegin () const noexcept
 Gets the beginning const iterator of the sequence.
 
constexpr inline const_iterator cend () const noexcept
 Gets the end const iterator of the sequence.
 
constexpr inline const_reverse_iterator crbegin () const noexcept
 Gets the beginning const reverse iterator of the sequence.
 
constexpr inline const_reverse_iterator crend () const noexcept
 Gets the end const reverse iterator of the sequence.
 
constexpr inline bool empty () const noexcept
 Checks if the sequence is empty.
 
constexpr inline difference_type size () const noexcept
 Gets the size of the sequence.
 
constexpr inline value_type operator[] (difference_type n) const noexcept
 Accesses an element by index.
 
constexpr inline value_type at (difference_type n) const noexcept
 Accesses an element by index with bounds checking.
 
constexpr inline value_type front () const noexcept
 Accesses the first element in the sequence.
 
constexpr inline value_type back () const noexcept
 Accesses the last element in the sequence.
 

Detailed Description

template<typename T>
class ipaddress::subnets_sequence< T >

A sequence container for subnet ranges within a network.

This class template represents a sequence of subnets within a network. It provides forward and reverse iterators to traverse the subnets and offers insight into the structure of a network by breaking it down into smaller, manageable parts.

Template Parameters
TThe type of IP network to be divided into subnets.
Remarks
When iterating, obtaining networks occurs through lazy calculations.

Constructor & Destructor Documentation

◆ subnets_sequence() [1/2]

template<typename T >
constexpr inline subnets_sequence ( const ip_address_type & network_address,
size_t new_prefixlen )
inlinenoexcept

Constructs a sequence of subnets from a single network address with a new prefix length.

Initializes the sequence to represent subnets derived from the provided network address, each with the specified new prefix length. This constructor is typically used when the entire network is to be subdivided into subnets of equal size.

Parameters
[in]network_addressThe base network address for the sequence.
[in]new_prefixlenThe new prefix length for the subnets.

◆ subnets_sequence() [2/2]

template<typename T >
constexpr inline subnets_sequence ( const ip_address_type & network_address,
const ip_address_type & broadcast_address,
const ip_address_type & hostmask,
size_t prefixlen_diff,
size_t new_prefixlen )
inlinenoexcept

Constructs a sequence of subnets from a network address range with a new prefix length.

Initializes the sequence to represent subnets derived from the provided network address range, each with the specified new prefix length.

Parameters
[in]network_addressThe starting network address for the sequence.
[in]broadcast_addressThe broadcast address of the network.
[in]hostmaskThe hostmask of the network.
[in]prefixlen_diffThe difference in prefix length from the original network to the subnets.
[in]new_prefixlenThe new prefix length for the subnets.

Member Function Documentation

◆ begin()

template<typename T >
constexpr inline const_iterator begin ( ) const
inlinenoexcept

Gets the beginning iterator of the sequence.

Returns
A const_iterator to the first element in the sequence.

◆ end()

template<typename T >
constexpr inline const_iterator end ( ) const
inlinenoexcept

Gets the end iterator of the sequence.

Returns
A const_iterator to the element following the last element in the sequence.

◆ rbegin()

template<typename T >
constexpr inline const_reverse_iterator rbegin ( ) const
inlinenoexcept

Gets the beginning reverse iterator of the sequence.

Returns
A const_reverse_iterator to the first element of the reversed sequence.

◆ rend()

template<typename T >
constexpr inline const_reverse_iterator rend ( ) const
inlinenoexcept

Gets the end reverse iterator of the sequence.

Returns
A const_reverse_iterator to the element following the last element of the reversed sequence.

◆ cbegin()

template<typename T >
constexpr inline const_iterator cbegin ( ) const
inlinenoexcept

Gets the beginning const iterator of the sequence.

Returns
A const_iterator to the first element in the sequence.

◆ cend()

template<typename T >
constexpr inline const_iterator cend ( ) const
inlinenoexcept

Gets the end const iterator of the sequence.

Returns
A const_iterator to the element following the last element in the sequence.

◆ crbegin()

template<typename T >
constexpr inline const_reverse_iterator crbegin ( ) const
inlinenoexcept

Gets the beginning const reverse iterator of the sequence.

Returns
A const_reverse_iterator to the first element of the reversed sequence.

◆ crend()

template<typename T >
constexpr inline const_reverse_iterator crend ( ) const
inlinenoexcept

Gets the end const reverse iterator of the sequence.

Returns
A const_reverse_iterator to the element following the last element of the reversed sequence.

◆ empty()

template<typename T >
constexpr inline bool empty ( ) const
inlinenoexcept

Checks if the sequence is empty.

Returns
true if the sequence is empty, false otherwise.

◆ size()

template<typename T >
constexpr inline difference_type size ( ) const
inlinenoexcept

Gets the size of the sequence.

Returns
The number of elements in the sequence.

◆ operator[]()

template<typename T >
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.

◆ at()

template<typename T >
constexpr inline value_type at ( difference_type n) const
inlinenoexcept

Accesses an element by index with bounds checking.

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

◆ front()

template<typename T >
constexpr inline value_type front ( ) const
inlinenoexcept

Accesses the first element in the sequence.

Returns
A reference to the first element in the sequence.

◆ back()

template<typename T >
constexpr inline value_type back ( ) const
inlinenoexcept

Accesses the last element in the sequence.

Returns
A reference to the last element in the sequence.

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