[#boost-urls-static_url-2constructor-08] = xref:boost/urls/static_url/2constructor-08.adoc[boost::urls::static_url::static_url] :relfileprefix: ../../../ :mrdocs: Constructor == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/static_url.hpp#L217[boost/url/static_url.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit static_url(core::string_view s); ---- == Description This function constructs a url from the string `s`, which must contain a valid _URI_ or _relative‐ref_ or else an exception is thrown. The new url retains ownership by making a copy of the passed string. == Example [,cpp] ---- static_url< 1024 > u( "https://www.example.com" ); ---- == Effects [,cpp] ---- return static_url( parse_uri_reference( s ).value() ); ---- == Postconditions [,cpp] ---- this->buffer().data() != s.data() ---- == Complexity Linear in `s.size()`. == Exception Safety Exceptions thrown on invalid input. == 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[] == Exceptions [cols=2] |=== | Name | Thrown on | `system_error` | The input does not contain a valid url. |=== == Parameters [cols=2] |=== | Name | Description | *s* | The string to parse. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#