:relfileprefix: ../../../
[#boost-urls-url_view_base-host_address]

== xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url_view_base.adoc[pass:[url_view_base]]::host_address


Return the host


=== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1124[boost/url/url_view_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<class StringToken = xref:boost/urls/string_token.adoc[string_token]::xref:boost/urls/string_token/return_string.adoc[return_string]>
StringToken::result_type
host_address(StringToken&& token) const;
----

=== Description


The value returned by this function
depends on the type of host returned
from the function
xref:boost/urls/url_view_base/host_type.adoc[host_type]
.

* If the type is
xref:boost/urls/host_type/ipv4.adoc[host_type::ipv4]
,        then the IPv4 address string is returned.

* If the type is
xref:boost/urls/host_type/ipv6.adoc[host_type::ipv6]
,        then the IPv6 address string is returned,
without any enclosing brackets.

* If the type is
xref:boost/urls/host_type/ipvfuture.adoc[host_type::ipvfuture]
,        then the IPvFuture address string is returned,
without any enclosing brackets.

* If the type is
xref:boost/urls/host_type/name.adoc[host_type::name]
,        then the host name string is returned.
Any percent-escapes in the string are
decoded first.

* If the type is
xref:boost/urls/host_type/none.adoc[host_type::none]
,        then an empty string is returned.
[,cpp]
----
assert( url_view( "https://[1::6:c0a8:1]/" ).host_address() == "1::6:c0a8:1" );
----

=== Linear in `this-&gt;host_address().size()`.

=== Calls to allocate may throw.
[,cpp]
----
host        = IP-literal / IPv4address / reg-name

IP-literal  = "[" ( IPv6address / IPvFuture  ) "]"

reg-name    = *( unreserved / pct-encoded / "-" / ".")
----

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[3.2.2. Host (rfc3986)]








