:relfileprefix: ../../../
[#boost-urls-authority_view-host]

== xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/authority_view.adoc[pass:[authority_view]]::host


Return the host


=== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/authority_view.hpp#L701[boost/url/authority_view.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(StringToken&& token) const;
----

=== Description


This function returns the host portion
of the authority as a string, or the
empty string if there is no authority.
Any percent-escapes in the string are
decoded first.
[,cpp]
----
assert( url_view( "https://www%2droot.example.com/" ).host() == "www-root.example.com" );
----

=== Linear in `this-&gt;host().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)]








