[#boost-urls-url_view_base-host] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url_view_base]::host :relfileprefix: ../../../ :mrdocs: Return the host == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1011[boost/url/url_view_base.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<xref:boost/urls/string_token.adoc[string_token]::xref:boost/urls/string_token/StringToken.adoc[StringToken] 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 = {}); ---- == 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. === Example [,cpp] ---- assert( url_view( "https://www%2droot.example.com/" ).host() == "www-root.example.com" ); ---- === Complexity Linear in `this‐>host().size()`. === Exception Safety Calls to allocate may throw. === BNF [,cpp] ---- host = IP-literal / IPv4address / reg-name IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-encoded / "-" / ".") ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[3.2.2. Host (rfc3986)] Return the host 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. === Example [,cpp] ---- assert( url_view( "https://www%2droot.example.com/" ).host() == "www-root.example.com" ); ---- === Complexity Linear in `this‐>host().size()`. === Exception Safety Calls to allocate may throw. === BNF [,cpp] ---- host = IP-literal / IPv4address / reg-name IP-literal = "[" ( IPv6address / IPvFuture ) "]" reg-name = *( unreserved / pct-encoded / "-" / ".") ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[3.2.2. Host (rfc3986)] [.small]#Created with https://www.mrdocs.com[MrDocs]#