21 Internet protocol [internet]

21.10 Class template ip::basic_address_range specializations [internet.address.range]

The class template basic_address_range represents a range of IP addresses in network byte order. This clause defines two specializations of the class template basic_address_range: basic_address_range<address_v4> and basic_address_range<address_v6>. The members and operational semantics of these specializations are defined below.

namespace std {
namespace experimental {
namespace net {
inline namespace v1 {
namespace ip {

  template<> class basic_address_range<Address>
  {
  public:
    // types:
    using iterator = basic_address_iterator<Address>;

    // constructors:
    basic_address_range() noexcept;
    basic_address_range(const Address& first,
                        const Address& last) noexcept;

    // members:
    iterator begin() const noexcept;
    iterator end() const noexcept;
    bool empty() const noexcept;
    size_t size() const noexcept; // not always defined
    iterator find(const Address& addr) const noexcept;
  };

} // namespace ip
} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std

Specializations of basic_address_range satisfy the requirements for Destructible (C++ 2014 [destructible]), CopyConstructible (C++ 2014 [copyconstructible]), and CopyAssignable (C++ 2014 [copyassignable]).

basic_address_range() noexcept;

Effects: Constructs an object of type basic_address_range<Address> that represents an empty range.

basic_address_range(const Address& first, const Address& last) noexcept;

Effects: Constructs an object of type basic_address_range<Address> that represents the half-open range [first, last).

iterator begin() const noexcept;

Returns: An iterator that points to the beginning of the range.

iterator end() const noexcept;

Returns: An iterator that points to the end of the range.

bool empty() const noexcept;

Returns: true if *this represents an empty range, otherwise false.

size_t size() const noexcept;

Returns: The number of unique addresses in the range.

Remarks: This member function is not defined when Address is type address_v6.

iterator find(const Address& addr) const noexcept;

Returns: If addr is in the range, an iterator that points to addr; otherwise, end().

Complexity: Constant time.