:relfileprefix: ../../../
[#C97B146516E2FB02272EA694515CBD6FB9C8201A]

= Function url_view_base::encoded_host_address

pass:v,q[Return the host]


== Synopsis

Declared in header `</boost/url/url_view_base.hpp#L1170[boost/url/url_view_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/pct_string_view.adoc[pct_string_view]
encoded_host_address() const noexcept;
----

== Description

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

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

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

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

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

* pass:v,q[If the type is]
xref:boost/urls/host_type/none.adoc[host_type::none,]
pass:v,q[then an empty string is returned.]
pass:v,q[The returned string may contain]
pass:v,q[percent escapes.]

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

=== Complexity
pass:v,q[Constant.]

=== Exception Safety
pass:v,q[Throws nothing.]

=== 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 Value

* `pct_string_view` 




