[#boost-urls-url-2constructor-002]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url.adoc[url]::url
:relfileprefix: ../../../
:mrdocs:

Constructor

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
url(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; The new url retains ownership by allocating a copy of the passed string&period;

== Example

[,cpp]
----
url u( "https://www.example.com" );
----
== Effects

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

[,cpp]
----
this->buffer().data() != s.data()
----
== Complexity

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

== Exception Safety

Calls to allocate may throw&period; Exceptions thrown on invalid input&period;

== BNF

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

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

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

== Exceptions

[cols="1,4"]
|===
| Name
| Thrown on
| `system&lowbar;error`
| The input does not contain a valid url&period;
|===

== Parameters

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

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


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