1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
// ip/address_v6_range.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Oliver Kowalke (oliver dot kowalke at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
#define BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/ip/address_v6_iterator.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace ip {
template <typename> class basic_address_range;
/// Represents a range of IPv6 addresses.
/**
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
template <> class basic_address_range<address_v6>
{
public:
/// The type of an iterator that points into the range.
typedef basic_address_iterator<address_v6> iterator;
/// Construct an empty range.
basic_address_range() noexcept
: begin_(address_v6()),
end_(address_v6())
{
}
/// Construct an range that represents the given range of addresses.
explicit basic_address_range(const iterator& first,
const iterator& last) noexcept
: begin_(first),
end_(last)
{
}
/// Copy constructor.
basic_address_range(const basic_address_range& other) noexcept
: begin_(other.begin_),
end_(other.end_)
{
}
/// Move constructor.
basic_address_range(basic_address_range&& other) noexcept
: begin_(static_cast<iterator&&>(other.begin_)),
end_(static_cast<iterator&&>(other.end_))
{
}
/// Assignment operator.
basic_address_range& operator=(
const basic_address_range& other) noexcept
{
begin_ = other.begin_;
end_ = other.end_;
return *this;
}
/// Move assignment operator.
basic_address_range& operator=(basic_address_range&& other) noexcept
{
begin_ = static_cast<iterator&&>(other.begin_);
end_ = static_cast<iterator&&>(other.end_);
return *this;
}
/// Obtain an iterator that points to the start of the range.
iterator begin() const noexcept
{
return begin_;
}
/// Obtain an iterator that points to the end of the range.
iterator end() const noexcept
{
return end_;
}
/// Determine whether the range is empty.
bool empty() const noexcept
{
return begin_ == end_;
}
/// Find an address in the range.
iterator find(const address_v6& addr) const noexcept
{
return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
}
private:
iterator begin_;
iterator end_;
};
/// Represents a range of IPv6 addresses.
typedef basic_address_range<address_v6> address_v6_range;
} // namespace ip
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP