2 // ip/address_v6_range.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Oliver Kowalke (oliver dot kowalke at gmail dot com)
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
13 #define BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/asio/detail/config.hpp>
20 #include <boost/asio/ip/address_v6_iterator.hpp>
22 #include <boost/asio/detail/push_options.hpp>
28 template <typename> class basic_address_range;
30 /// Represents a range of IPv6 addresses.
33 * @e Distinct @e objects: Safe.@n
34 * @e Shared @e objects: Unsafe.
36 template <> class basic_address_range<address_v6>
39 /// The type of an iterator that points into the range.
40 typedef basic_address_iterator<address_v6> iterator;
42 /// Construct an empty range.
43 basic_address_range() BOOST_ASIO_NOEXCEPT
44 : begin_(address_v6()),
49 /// Construct an range that represents the given range of addresses.
50 explicit basic_address_range(const iterator& first,
51 const iterator& last) BOOST_ASIO_NOEXCEPT
58 basic_address_range(const basic_address_range& other) BOOST_ASIO_NOEXCEPT
59 : begin_(other.begin_),
64 #if defined(BOOST_ASIO_HAS_MOVE)
66 basic_address_range(basic_address_range&& other) BOOST_ASIO_NOEXCEPT
67 : begin_(BOOST_ASIO_MOVE_CAST(iterator)(other.begin_)),
68 end_(BOOST_ASIO_MOVE_CAST(iterator)(other.end_))
71 #endif // defined(BOOST_ASIO_HAS_MOVE)
73 /// Assignment operator.
74 basic_address_range& operator=(
75 const basic_address_range& other) BOOST_ASIO_NOEXCEPT
77 begin_ = other.begin_;
82 #if defined(BOOST_ASIO_HAS_MOVE)
83 /// Move assignment operator.
84 basic_address_range& operator=(
85 basic_address_range&& other) BOOST_ASIO_NOEXCEPT
87 begin_ = BOOST_ASIO_MOVE_CAST(iterator)(other.begin_);
88 end_ = BOOST_ASIO_MOVE_CAST(iterator)(other.end_);
91 #endif // defined(BOOST_ASIO_HAS_MOVE)
93 /// Obtain an iterator that points to the start of the range.
94 iterator begin() const BOOST_ASIO_NOEXCEPT
99 /// Obtain an iterator that points to the end of the range.
100 iterator end() const BOOST_ASIO_NOEXCEPT
105 /// Determine whether the range is empty.
106 bool empty() const BOOST_ASIO_NOEXCEPT
108 return begin_ == end_;
111 /// Find an address in the range.
112 iterator find(const address_v6& addr) const BOOST_ASIO_NOEXCEPT
114 return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
122 /// Represents a range of IPv6 addresses.
123 typedef basic_address_range<address_v6> address_v6_range;
129 #include <boost/asio/detail/pop_options.hpp>
131 #endif // BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP