[#boost-urls-static_url-set_host_name] = xref:boost/urls/static_url/set_host_name.adoc[boost::urls::static_url::set_host_name] :relfileprefix: ../../../ :mrdocs: Set the host to a name == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/static_url.hpp#L390[boost/url/static_url.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:boost/urls/static_url.adoc[static_url]& set_host_name(core::string_view s); ---- == Description The host is set to the specified string, which may be empty. Reserved characters in the string are percent‐escaped in the result. The host type is xref:boost/urls/host_type.adoc[`host_type::name`]. == Example [,cpp] ---- assert( url( "http://www.example.com/index.htm").set_host_name( "localhost" ).host_address() == "localhost" ); ---- == Postconditions [,cpp] ---- this->has_authority() == true && this->host_ipv6_address() == addr && this->host_type() == host_type::name ---- == Exception Safety Strong guarantee. Calls to allocate may throw. == BNF [,cpp] ---- reg-name = *( unreserved / pct-encoded / "-" / ".") ---- == Specification * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[] == Return Value `*this` == Parameters [cols=2] |=== | Name | Description | *s* | The string to set. |=== == See Also xref:boost/urls/static_url/set_encoded_host.adoc[`set_encoded_host`], xref:boost/urls/static_url/set_encoded_host_address.adoc[`set_encoded_host_address`], xref:boost/urls/static_url/set_encoded_host_name.adoc[`set_encoded_host_name`], xref:boost/urls/static_url/set_host.adoc[`set_host`], xref:boost/urls/static_url/set_host_address.adoc[`set_host_address`], xref:boost/urls/static_url/set_host_ipv4.adoc[`set_host_ipv4`], xref:boost/urls/static_url/set_host_ipv6.adoc[`set_host_ipv6`], xref:boost/urls/static_url/set_host_ipvfuture.adoc[`set_host_ipvfuture`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#