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

Set the scheme

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/url.adoc[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

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

== Return Value

`&ast;this`

== Parameters

[cols=2]
|===
| Name
| Description
| *s*
| The scheme to set&period;
|===

== See Also

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


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