[#boost-urls-url_view-2constructor-00] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view.adoc[url_view]::url_view :relfileprefix: ../../../ :mrdocs: Constructor == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view.hpp#L200[boost/url/url_view.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class String> requires std::is_convertible< String, core::string_view >::value && !std::is_convertible< String*, url_view_base* >::value url_view(String const& 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. Upon successful construction, the view refers to the characters in the buffer pointed to by `s`. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of the buffer extends until it is no longer referenced. == Example [,cpp] ---- url_view u( "http://www.example.com/index.htm" ); ---- == Effects [,cpp] ---- return parse_uri_reference( s ).value(); ---- == 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[] == Parameters [cols=2] |=== | Name | Description | *s* | The string to parse. |=== == See Also xref:boost/urls/parse_uri_reference.adoc[`parse_uri_reference`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#