[#boost-urls-authority_view-user]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/authority_view.adoc[authority&lowbar;view]::user
:relfileprefix: ../../../
:mrdocs:

Return the user

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/authority_view.hpp#Lundefined[boost&sol;url&sol;authority&lowbar;view&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
user(StringToken&& token) const;
----

== Description

If present, this function returns a string representing the user (which may be empty)&period; Otherwise it returns an empty string&period; Any percent&hyphen;escapes in the string are decoded first&period;

== Example

[,cpp]
----
assert( url_view( "http://jane%2Ddoe:pass@example.com" ).user() == "jane-doe" );
----
== Complexity

Linear in `this&hyphen;&gt;user()&period;size()`&period;

== Exception Safety

Calls to allocate may throw&period;

== BNF

[,cpp]
----
userinfo    = user [ ":" [ password ] ]

user        = *( unreserved / pct-encoded / sub-delims )
password    = *( unreserved / pct-encoded / sub-delims / ":" )
----
== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1[3&period;2&period;1&period; User Information (rfc3986)]

== Return Value

The user

== Parameters

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

| *token*
| A string token to receive the result&period;
|===

== See Also

xref:boost/urls/authority_view/has_password.adoc[`has&lowbar;password`], xref:boost/urls/authority_view/has_userinfo.adoc[`has&lowbar;userinfo`], xref:boost/urls/authority_view/encoded_password.adoc[`encoded&lowbar;password`], xref:boost/urls/authority_view/encoded_user.adoc[`encoded&lowbar;user`], xref:boost/urls/authority_view/encoded_userinfo.adoc[`encoded&lowbar;userinfo`], xref:boost/urls/authority_view/password.adoc[`password`], xref:boost/urls/authority_view/userinfo.adoc[`userinfo`]&period;


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