The class network_v6 provides the ability to use and manipulate IPv6 network addresses.
namespace std { namespace experimental { namespace net { inline namespace v1 { namespace ip { class network_v6 { public: // [internet.network.v6.cons], constructors: constexpr network_v6() noexcept; constexpr network_v6(const address_v6& addr, int prefix_len); // [internet.network.v6.members], members: constexpr address_v6 address() const noexcept; constexpr int prefix_length() const noexcept; constexpr address_v6 network() const noexcept; address_v6_range hosts() const noexcept; constexpr network_v6 canonical() const noexcept; constexpr bool is_host() const noexcept; constexpr bool is_subnet_of(const network_v6& other) const noexcept; template<class Allocator = allocator<char>> basic_string<char, char_traits<char>, Allocator> to_string(const Allocator& a = Allocator()) const; }; // [internet.network.v6.comparisons], network_v6 comparisons: constexpr bool operator==(const network_v6& a, const network_v6& b) noexcept; constexpr bool operator!=(const network_v6& a, const network_v6& b) noexcept; // [internet.network.v6.creation], network_v6 creation: constexpr network_v6 make_network_v6(const address_v6& addr, int prefix_len); network_v6 make_network_v6(const char* str); network_v6 make_network_v6(const char* str, error_code& ec) noexcept; network_v6 make_network_v6(const string& str); network_v6 make_network_v6(const string& str, error_code& ec) noexcept; network_v6 make_network_v6(string_view str); network_v6 make_network_v6(string_view str, error_code& ec) noexcept; // [internet.network.v6.io], network_v6 I/O: template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<( basic_ostream<CharT, Traits>& os, const network_v6& net); } // namespace ip } // inline namespace v1 } // namespace net } // namespace experimental } // namespace std
network_v6 satisfies the requirements for Destructible (C++ 2014 [destructible]), CopyConstructible (C++ 2014 [copyconstructible]), and CopyAssignable (C++ 2014 [copyassignable]).
constexpr network_v6() noexcept;
Postconditions: this->address().is_unspecified() == true and prefix_length() == 0.
constexpr network_v6(const address_v6& addr, int prefix_len);
Postconditions: this->address() == addr and prefix_length() == prefix_len.
Remarks: out_of_range if prefix_len < 0 or prefix_len > 128.
constexpr address_v6 address() const noexcept;
Returns: The address specified when the network_v6 object was constructed.
constexpr int prefix_length() const noexcept;
Returns: The prefix length of the network.
constexpr address_v6 network() const noexcept;
Returns: An address_v6 object with the first prefix_length() bits, starting from the most significant bit in network byte order, set to the corresponding bit value of this->address(). All other bits are zero.
address_v6_range hosts() const noexcept;
Returns: If is_host() is true, an address_v6_range object representing the single address this->address(). Otherwise, an address_v6_range object representing the range of unique host IP addresses in the network.
constexpr network_v6 canonical() const noexcept;
Returns: network_v6(network(), prefix_length()).
constexpr bool is_host() const noexcept;
Returns: prefix_length() == 128.
constexpr bool is_subnet_of(const network_v6& other) const noexcept;
Returns: true if other.prefix_length() < prefix_length() and network_v6(this->address(), other.prefix_length()).canonical() == other.canonical(), otherwise false.
template<class Allocator = allocator<char>>
basic_string<char, char_traits<char>, Allocator>
to_string(const Allocator& a = Allocator()) const;
Returns: this->address().to_string(a) + "/" + to_string(prefix_length()).c_str().
constexpr bool operator==(const network_v6& a, const network_v6& b) noexcept;
Returns: true if a.address() == b.address() and a.prefix_length() == b.prefix_length(), otherwise false.
constexpr bool operator!=(const network_v6& a, const network_v6& b) noexcept;
Returns: !(a == b).
constexpr network_v6 make_network_v6(const address_v6& addr, int prefix_len);
Returns: network_v6(addr, prefix_len).
network_v6 make_network_v6(const char* str);
network_v6 make_network_v6(const char* str, error_code& ec) noexcept;
network_v6 make_network_v6(const string& str);
network_v6 make_network_v6(const string& str, error_code& ec) noexcept;
network_v6 make_network_v6(string_view str);
network_v6 make_network_v6(string_view str, error_code& ec) noexcept;
Returns: If str contains a value of the form address '/' prefix-length, a network_v6 object constructed with the result of applying make_address_v6() to the address portion of the string, and the result of converting prefix-length to an integer of type int. Otherwise returns network_v6() and sets ec to reflect the error.
template<class CharT, class Traits>
basic_ostream<CharT, Traits>& operator<<(
basic_ostream<CharT, Traits>& os, const network_v6& net);
Returns: os << net.to_string().c_str().