[#boost-urls-url_view-2constructor-025]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view.adoc[url&lowbar;view]::url&lowbar;view
:relfileprefix: ../../../
:mrdocs:


Constructor

== Synopsis


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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
url&lowbar;view(core::string&lowbar;view s);
----

== Description


This function constructs a URL from        the string `s`, which must contain a        valid _URI_ or _relative&hyphen;ref_        or else an exception is thrown&period; Upon        successful construction, the view        refers to the characters in the        buffer pointed to by `s`&period;        Ownership is not transferred&semi; The caller        is responsible for ensuring that the        lifetime of the buffer extends until        it is no longer referenced&period;


=== Example

[,cpp]
----
url_view u( "http://www.example.com/index.htm" );
----

=== Effects

[,cpp]
----
return parse_uri_reference( s ).value();
----

=== Complexity

Linear in `s&period;size()`&period;


=== Exception Safety

Exceptions thrown on invalid input&period;


=== BNF

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

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

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-4.1[4&period;1&period; URI Reference]

Constructor

This function constructs a URL from        the string `s`, which must contain a        valid _URI_ or _relative&hyphen;ref_        or else an exception is thrown&period; Upon        successful construction, the view        refers to the characters in the        buffer pointed to by `s`&period;        Ownership is not transferred&semi; The caller        is responsible for ensuring that the        lifetime of the buffer extends until        it is no longer referenced&period;


=== Example

[,cpp]
----
url_view u( "http://www.example.com/index.htm" );
----

=== Effects

[,cpp]
----
return parse_uri_reference( s ).value();
----

=== Complexity

Linear in `s&period;size()`&period;


=== Exception Safety

Exceptions thrown on invalid input&period;


=== BNF

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

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

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-4.1[4&period;1&period; URI Reference]



== Exceptions


|===
| Name | Thrown on

| `system&lowbar;error`
| The input failed to parse correctly&period;


| `system&lowbar;error`
| The input failed to parse correctly&period;


|===

== Parameters


|===
| Name | Description

| *s*
| The string to parse&period;


| *s*
| The string to parse&period;


|===

== See Also


xref:boost/urls/parse_uri_reference.adoc[parse&lowbar;uri&lowbar;reference]&period;



xref:boost/urls/parse_uri_reference.adoc[parse&lowbar;uri&lowbar;reference]&period;






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