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

Set the scheme

== Synopsis

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

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

== Description

This function sets the scheme to the specified known xref:boost/urls/scheme.adoc[`urls&colon;&colon;scheme`] id, which may not be xref:boost/urls/scheme.adoc[`scheme&colon;&colon;unknown`] or else an exception is thrown&period; If the id is xref:boost/urls/scheme.adoc[`scheme&colon;&colon;none`], this function behaves as if xref:boost/urls/url_base/remove_scheme.adoc[`remove&lowbar;scheme`] were called&period;

== Example

[,cpp]
----
assert( url( "http://example.com/echo.cgi" ).set_scheme_id( scheme::wss ).buffer() == "wss://example.com/echo.cgi" );
----
== Complexity

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

== Exception Safety

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

== Specification

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

== Return Value

`&ast;this`

== Parameters

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

| *id*
| The scheme to set&period;
|===


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