[#boost-urls-parse_uri_reference]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::parse&lowbar;uri&lowbar;reference
:relfileprefix: ../../
:mrdocs:

Return a reference to a parsed URL string

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
system::result&lt;url&lowbar;view&gt;
parse&lowbar;uri&lowbar;reference(core::string&lowbar;view s);
----

== Description

This function parses a string according to the grammar below and returns a view referencing the passed string upon success, else returns an error&period; Ownership of the string is not transferred&semi; the caller is responsible for ensuring that the lifetime of the character buffer extends until the view is no longer being accessed&period;

== Example

[,cpp]
----
system::result< url_view > = parse_uri_reference( "ws://echo.example.com/?name=boost#demo" );
----
== BNF

[,cpp]
----
URI-reference = URI / relative-ref

URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

relative-ref  = relative-part [ "?" query ] [ "#" fragment ]

hier-part     = "//" authority path-abempty
              / path-absolute
              / path-rootless
              / path-empty

relative-part = "//" authority path-abempty
              / path-absolute
              / path-noscheme
              / path-abempty
              / path-empty
----
== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-4.1[4&period;1&period; URI Reference (rfc3986)]
* https://www.rfc-editor.org/errata/eid5428[Errata ID&colon; 5428 (rfc3986)]

== Exceptions

[cols="1,4"]
|===
| Name
| Thrown on
| `std&colon;&colon;length&lowbar;error`
| `s&period;size() &gt; url&lowbar;view&colon;&colon;max&lowbar;size`
|===

== Return Value

A view to the parsed URL

== Parameters

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

| *s*
| The string to parse
|===

== See Also

xref:boost/urls/parse_absolute_uri.adoc[`parse&lowbar;absolute&lowbar;uri`], xref:boost/urls/parse_origin_form.adoc[`parse&lowbar;origin&lowbar;form`], xref:boost/urls/parse_relative_ref.adoc[`parse&lowbar;relative&lowbar;ref`], xref:boost/urls/parse_uri.adoc[`parse&lowbar;uri`], xref:boost/urls/url_view.adoc[`url&lowbar;view`]&period;


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