Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:00

0001 //
0002 // ip/address_v6_range.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //                         Oliver Kowalke (oliver dot kowalke at gmail dot com)
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 
0012 #ifndef BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
0013 #define BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP
0014 
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0018 
0019 #include <boost/asio/detail/config.hpp>
0020 #include <boost/asio/ip/address_v6_iterator.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 namespace ip {
0027 
0028 template <typename> class basic_address_range;
0029 
0030 /// Represents a range of IPv6 addresses.
0031 /**
0032  * @par Thread Safety
0033  * @e Distinct @e objects: Safe.@n
0034  * @e Shared @e objects: Unsafe.
0035  */
0036 template <> class basic_address_range<address_v6>
0037 {
0038 public:
0039   /// The type of an iterator that points into the range.
0040   typedef basic_address_iterator<address_v6> iterator;
0041 
0042   /// Construct an empty range.
0043   basic_address_range() noexcept
0044     : begin_(address_v6()),
0045       end_(address_v6())
0046   {
0047   }
0048 
0049   /// Construct an range that represents the given range of addresses.
0050   explicit basic_address_range(const iterator& first,
0051       const iterator& last) noexcept
0052     : begin_(first),
0053       end_(last)
0054   {
0055   }
0056 
0057   /// Copy constructor.
0058   basic_address_range(const basic_address_range& other) noexcept
0059     : begin_(other.begin_),
0060       end_(other.end_)
0061   {
0062   }
0063 
0064   /// Move constructor.
0065   basic_address_range(basic_address_range&& other) noexcept
0066     : begin_(static_cast<iterator&&>(other.begin_)),
0067       end_(static_cast<iterator&&>(other.end_))
0068   {
0069   }
0070 
0071   /// Assignment operator.
0072   basic_address_range& operator=(
0073       const basic_address_range& other) noexcept
0074   {
0075     begin_ = other.begin_;
0076     end_ = other.end_;
0077     return *this;
0078   }
0079 
0080   /// Move assignment operator.
0081   basic_address_range& operator=(basic_address_range&& other) noexcept
0082   {
0083     begin_ = static_cast<iterator&&>(other.begin_);
0084     end_ = static_cast<iterator&&>(other.end_);
0085     return *this;
0086   }
0087 
0088   /// Obtain an iterator that points to the start of the range.
0089   iterator begin() const noexcept
0090   {
0091     return begin_;
0092   }
0093 
0094   /// Obtain an iterator that points to the end of the range.
0095   iterator end() const noexcept
0096   {
0097     return end_;
0098   }
0099 
0100   /// Determine whether the range is empty.
0101   bool empty() const noexcept
0102   {
0103     return begin_ == end_;
0104   }
0105 
0106   /// Find an address in the range.
0107   iterator find(const address_v6& addr) const noexcept
0108   {
0109     return addr >= *begin_ && addr < *end_ ? iterator(addr) : end_;
0110   }
0111 
0112 private:
0113   iterator begin_;
0114   iterator end_;
0115 };
0116 
0117 /// Represents a range of IPv6 addresses.
0118 typedef basic_address_range<address_v6> address_v6_range;
0119 
0120 } // namespace ip
0121 } // namespace asio
0122 } // namespace boost
0123 
0124 #include <boost/asio/detail/pop_options.hpp>
0125 
0126 #endif // BOOST_ASIO_IP_ADDRESS_V6_RANGE_HPP