File indexing completed on 2025-01-18 09:28:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_IP_ADDRESS_V4_RANGE_HPP
0012 #define BOOST_ASIO_IP_ADDRESS_V4_RANGE_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/ip/address_v4_iterator.hpp>
0020
0021 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025 namespace ip {
0026
0027 template <typename> class basic_address_range;
0028
0029
0030
0031
0032
0033
0034
0035 template <> class basic_address_range<address_v4>
0036 {
0037 public:
0038
0039 typedef basic_address_iterator<address_v4> iterator;
0040
0041
0042 basic_address_range() noexcept
0043 : begin_(address_v4()),
0044 end_(address_v4())
0045 {
0046 }
0047
0048
0049 explicit basic_address_range(const iterator& first,
0050 const iterator& last) noexcept
0051 : begin_(first),
0052 end_(last)
0053 {
0054 }
0055
0056
0057 basic_address_range(const basic_address_range& other) noexcept
0058 : begin_(other.begin_),
0059 end_(other.end_)
0060 {
0061 }
0062
0063
0064 basic_address_range(basic_address_range&& other) noexcept
0065 : begin_(static_cast<iterator&&>(other.begin_)),
0066 end_(static_cast<iterator&&>(other.end_))
0067 {
0068 }
0069
0070
0071 basic_address_range& operator=(const basic_address_range& other) noexcept
0072 {
0073 begin_ = other.begin_;
0074 end_ = other.end_;
0075 return *this;
0076 }
0077
0078
0079 basic_address_range& operator=(basic_address_range&& other) noexcept
0080 {
0081 begin_ = static_cast<iterator&&>(other.begin_);
0082 end_ = static_cast<iterator&&>(other.end_);
0083 return *this;
0084 }
0085
0086
0087 iterator begin() const noexcept
0088 {
0089 return begin_;
0090 }
0091
0092
0093 iterator end() const noexcept
0094 {
0095 return end_;
0096 }
0097
0098
0099 bool empty() const noexcept
0100 {
0101 return size() == 0;
0102 }
0103
0104
0105 std::size_t size() const noexcept
0106 {
0107 return end_->to_uint() - begin_->to_uint();
0108 }
0109
0110
0111 iterator find(const address_v4& addr) const noexcept
0112 {
0113 return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
0114 }
0115
0116 private:
0117 iterator begin_;
0118 iterator end_;
0119 };
0120
0121
0122 typedef basic_address_range<address_v4> address_v4_range;
0123
0124 }
0125 }
0126 }
0127
0128 #include <boost/asio/detail/pop_options.hpp>
0129
0130 #endif