21 Internet protocol [internet]

21.5 Class ip::address_v4 [internet.address.v4]

21.5.6 ip::address_v4 creation [internet.address.v4.creation]

constexpr address_v4 make_address_v4(const address_v4::bytes_type& bytes);

Returns: address_v4(bytes).

constexpr address_v4 make_address_v4(address_v4::uint_type val);

Returns: address_v4(val).

constexpr address_v4 make_address_v4(v4_mapped_t, const address_v6& a);

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

address_v6::bytes_type v6b = a.to_bytes();
address_v4::bytes_type v4b(v6b[12], v6b[13], v6b[14], v6b[15]);
return address_v4(v4b);

Remarks: bad_address_cast if a.is_v4_mapped() is false.

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

Effects: Converts a textual representation of an address into a corresponding address_v4 value, as if by POSIX inet_pton when invoked with address family AF_INET.

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

Error conditions:

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