[#boost-urls-url_view_base-host_name]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base]::host&lowbar;name
:relfileprefix: ../../../
:mrdocs:

Return the host name

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#Lundefined[boost&sol;url&sol;url&lowbar;view&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:boost/urls/string_token/StringToken.adoc[string&lowbar;token::StringToken] StringToken = xref:boost/urls/string_token/return_string.adoc[string&lowbar;token::return&lowbar;string]&gt;
StringToken::result&lowbar;type
host&lowbar;name(StringToken&& token = &lcub;&rcub;) const;
----

== Description

If the host type is xref:boost/urls/host_type.adoc[`host&lowbar;type&colon;&colon;name`], this function returns the name as a string&period; Otherwise an empty string is returned&period; Any percent&hyphen;escapes in the string are decoded first&period;

== Example

[,cpp]
----
assert( url_view( "https://www%2droot.example.com/" ).host_name() == "www-root.example.com" );
----
== Complexity

Linear in `this&hyphen;&gt;host&lowbar;name()&period;size()`&period;

== Exception Safety

Calls to allocate may throw&period;

== BNF

[,cpp]
----
host        = IP-literal / IPv4address / reg-name

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

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

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[3&period;2&period;2&period; Host (rfc3986)]

== Return Value

The host name as a string&period;

== Parameters

[cols="1,4"]
|===
|Name|Description

| *token*
| A string token customization&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
