21 Internet protocol [internet]

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

21.6.3 ip::address_v6 members [internet.address.v6.members]

void scope_id(scope_id_type id) noexcept;

Postconditions: scope_id() == id.

constexpr scope_id_type scope_id() const noexcept;

Returns: The scope identifier associated with the address.

constexpr bool is_unspecified() const noexcept;

Returns: *this == make_address_v6("::").

constexpr bool is_loopback() const noexcept;

Returns: *this == make_address_v6("::1").

constexpr bool is_multicast() const noexcept;

Returns: A boolean indicating whether the address_v6 object represents a multicast address, as if computed by the following method:

bytes_type b = to_bytes();
return b[0] == 0xFF;

constexpr bool is_link_local() const noexcept;

Returns: A boolean indicating whether the address_v6 object represents a unicast link-local address, as if computed by the following method:

bytes_type b = to_bytes();
return b[0] == 0xFE && (b[1] & 0xC0) == 0x80;

constexpr bool is_site_local() const noexcept;

Returns: A boolean indicating whether the address_v6 object represents a unicast site-local address, as if computed by the following method:

bytes_type b = to_bytes();
return b[0] == 0xFE && (b[1] & 0xC0) == 0xC0;

constexpr bool is_v4_mapped() const noexcept;

Returns: A boolean indicating whether the address_v6 object represents an IPv4-mapped IPv6 address, as if computed by the following method:

bytes_type b = to_bytes();
return b[ 0] == 0 && b[ 1] == 0 && b[ 2] == 0    && b[ 3] == 0
    && b[ 4] == 0 && b[ 5] == 0 && b[ 6] == 0    && b[ 7] == 0
    && b[ 8] == 0 && b[ 9] == 0 && b[10] == 0xFF && b[11] == 0xFF;

constexpr bool is_multicast_node_local() const noexcept;

Returns: is_multicast() && (to_bytes()[1] & 0x0F) == 0x01.

constexpr bool is_multicast_link_local() const noexcept;

Returns: is_multicast() && (to_bytes()[1] & 0x0F) == 0x02.

constexpr bool is_multicast_site_local() const noexcept;

Returns: is_multicast() && (to_bytes()[1] & 0x0F) == 0x05.

constexpr bool is_multicast_org_local() const noexcept;

Returns: is_multicast() && (to_bytes()[1] & 0x0F) == 0x08.

constexpr bool is_multicast_global() const noexcept;

Returns: is_multicast() && (to_bytes()[1] & 0x0F) == 0x0E.

constexpr bytes_type to_bytes() const noexcept;

Returns: A representation of the address in network byte order ([defs.net.byte.order]).

template<class Allocator = allocator<char>> basic_string<char, char_traits<char>, Allocator> to_string(const Allocator& a = Allocator()) const;

Effects: Converts an address into a textual representation. If scope_id() == 0, converts as if by POSIX inet_ntop when invoked with address family AF_INET6. If scope_id() != 0, the format is address%scope-id, where address is the textual representation of the equivalent address having scope_id() == 0, and scope-id is an implementation-defined textual representation of the scope identifier.

Returns: If successful, the textual representation of the address. Otherwise basic_string<char, char_traits<char>, Allocator>(a).