[#boost-urls-static_url-set_scheme]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/static_url.adoc[static&lowbar;url]::set&lowbar;scheme
:relfileprefix: ../../../
:mrdocs:


Set the scheme

== Synopsis


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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/static_url.adoc[static&lowbar;url]&
set&lowbar;scheme(core::string&lowbar;view s);
----

== Description


The scheme is set to the specified        string, which must contain a valid        scheme without any trailing colon        (&apos;&colon;&apos;)&period;        Note that schemes are case&hyphen;insensitive,        and the canonical form is lowercased&period;


=== Example

[,cpp]
----
assert( url( "http://www.example.com" ).set_scheme( "https" ).scheme_id() == scheme::https );
----

=== Complexity

Linear in `this&hyphen;&gt;size() &plus; s&period;size()`&period;


=== Exception Safety

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


=== BNF

[,cpp]
----
scheme        = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.1[            3&period;1&period; Scheme (rfc3986)]



== Exceptions


|===
| Name | Thrown on

| `system&lowbar;error`
| `s` contains an invalid scheme&period;


|===

== Parameters


|===
| Name | Description

| *s*
| The scheme to set&period;


|===

== See Also


xref:boost/urls/url_base/remove_scheme.adoc[remove&lowbar;scheme]&period;






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