21 Internet protocol [internet]

21.6 Class ip::address_v6 [internet.address.v6]

21.6.6 ip::address_v6 creation [internet.address.v6.creation]

constexpr address_v6 make_address_v6(const address_v6::bytes_type& bytes, scope_id_type scope_id);

Returns: address_v6(bytes, scope_id).

constexpr address_v6 make_address_v6(v4_mapped_t, const address_v4& a) noexcept;

Returns: An address_v6 object containing the IPv4-mapped IPv6 address corresponding to the specified IPv4 address, as if computed by the following method:

address_v4::bytes_type v4b = a.to_bytes();
address_v6::bytes_type v6b(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                           0xFF, 0xFF, v4b[0], v4b[1], v4b[2], v4b[3]);
return address_v6(v6b);

address_v6 make_address_v6(const char* str); address_v6 make_address_v6(const char* str, error_code& ec) noexcept; address_v4 make_address_v6(const string& str); address_v4 make_address_v6(const string& str, error_code& ec) noexcept; address_v6 make_address_v6(string_view str); address_v6 make_address_v6(string_view str, error_code& ec) noexcept;

Effects: Converts a textual representation of an address into a corresponding address_v6 value. The format is either address or address%scope-id, where address is in the format specified by POSIX inet_pton when invoked with address family AF_INET6, and scope-id is an optional string specifying the scope identifier. All implementations accept as scope-id a textual representation of an unsigned decimal integer. It is implementation-defined whether alternative scope identifier representations are permitted. If scope-id is not supplied, an address_v6 object is returned such that scope_id() == 0.

Returns: If successful, an address_v6 value corresponding to the string str. Otherwise returns address_v6().

Error conditions:

  • errc::invalid_argument — if str is not a valid textual representation of an IPv6 address.