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

Return the userinfo

== 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
userinfo(StringToken&& token = &lcub;&rcub;) const;
----

== Description

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

[NOTE]
====
This function uses the string token return type customization&period; Depending on the token passed, the return type and behavior of the function can be different&period; See xref:boost/urls/string_token/return_string.adoc[`string&lowbar;token&colon;&colon;return&lowbar;string`] for more information&period;

====

== Example

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

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

== Exception Safety

Calls to allocate may throw&period;

== BNF

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

authority   = [ userinfo "@" ] host [ ":" port ]
----
== Specification

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

== Return Value

* When called with no arguments, a value of type `std&colon;&colon;string` is returned&period; Otherwise, the return type and meaning depends on the string token passed to the function&period;
* The userinfo as a string&period;

== Parameters

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

| *token*
| The string token to use&period;
|===

== See Also

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


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