Clementine
address_v6_range.hpp
1 //
2 // ip/address_v6_range.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Oliver Kowalke (oliver dot kowalke at gmail dot com)
7 //
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)
10 //
11 
12 #ifndef ASIO_IP_ADDRESS_V6_RANGE_HPP
13 #define ASIO_IP_ADDRESS_V6_RANGE_HPP
14 
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 
19 #include "asio/detail/config.hpp"
20 #include "asio/ip/address_v6_iterator.hpp"
21 
22 #include "asio/detail/push_options.hpp"
23 
24 namespace asio {
25 namespace ip {
26 
27 template <typename> class basic_address_range;
28 
30 
35 template <> class basic_address_range<address_v6>
36 {
37 public:
40 
42  basic_address_range() ASIO_NOEXCEPT
43  : begin_(address_v6()),
44  end_(address_v6())
45  {
46  }
47 
49  explicit basic_address_range(const iterator& first,
50  const iterator& last) ASIO_NOEXCEPT
51  : begin_(first),
52  end_(last)
53  {
54  }
55 
57  basic_address_range(const basic_address_range& other) ASIO_NOEXCEPT
58  : begin_(other.begin_),
59  end_(other.end_)
60  {
61  }
62 
63 #if defined(ASIO_HAS_MOVE)
64  basic_address_range(basic_address_range&& other) ASIO_NOEXCEPT
66  : begin_(ASIO_MOVE_CAST(iterator)(other.begin_)),
67  end_(ASIO_MOVE_CAST(iterator)(other.end_))
68  {
69  }
70 #endif // defined(ASIO_HAS_MOVE)
71 
74  const basic_address_range& other) ASIO_NOEXCEPT
75  {
76  begin_ = other.begin_;
77  end_ = other.end_;
78  return *this;
79  }
80 
81 #if defined(ASIO_HAS_MOVE)
82  basic_address_range& operator=(
84  basic_address_range&& other) ASIO_NOEXCEPT
85  {
86  begin_ = ASIO_MOVE_CAST(iterator)(other.begin_);
87  end_ = ASIO_MOVE_CAST(iterator)(other.end_);
88  return *this;
89  }
90 #endif // defined(ASIO_HAS_MOVE)
91 
93  iterator begin() const ASIO_NOEXCEPT
94  {
95  return begin_;
96  }
97 
99  iterator end() const ASIO_NOEXCEPT
100  {
101  return end_;
102  }
103 
105  bool empty() const ASIO_NOEXCEPT
106  {
107  return begin_ == end_;
108  }
109 
111  iterator find(const address_v6& addr) const ASIO_NOEXCEPT
112  {
113  return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
114  }
115 
116 private:
117  iterator begin_;
118  iterator end_;
119 };
120 
123 
124 } // namespace ip
125 } // namespace asio
126 
127 #include "asio/detail/pop_options.hpp"
128 
129 #endif // ASIO_IP_ADDRESS_V6_RANGE_HPP
basic_address_iterator< address_v6 > iterator
The type of an iterator that points into the range.
Definition: address_v6_range.hpp:39
iterator end() const ASIO_NOEXCEPT
Obtain an iterator that points to the end of the range.
Definition: address_v6_range.hpp:99
basic_address_range(const basic_address_range &other) ASIO_NOEXCEPT
Copy constructor.
Definition: address_v6_range.hpp:57
basic_address_range & operator=(const basic_address_range &other) ASIO_NOEXCEPT
Assignment operator.
Definition: address_v6_range.hpp:73
basic_address_range() ASIO_NOEXCEPT
Construct an empty range.
Definition: address_v6_range.hpp:42
basic_address_range(const iterator &first, const iterator &last) ASIO_NOEXCEPT
Construct an range that represents the given range of addresses.
Definition: address_v6_range.hpp:49
An input iterator that can be used for traversing IPv6 addresses.
Definition: address_v6_iterator.hpp:38
bool empty() const ASIO_NOEXCEPT
Determine whether the range is empty.
Definition: address_v6_range.hpp:105
iterator begin() const ASIO_NOEXCEPT
Obtain an iterator that points to the start of the range.
Definition: address_v6_range.hpp:93
Represents a range of IPv6 addresses.
Definition: address_v6_range.hpp:35
Implements IP version 6 style addresses.
Definition: address_v6.hpp:47
iterator find(const address_v6 &addr) const ASIO_NOEXCEPT
Find an address in the range.
Definition: address_v6_range.hpp:111
Definition: address_v4_range.hpp:26
Definition: any_io_executor.hpp:28