[#boost-urls-url_base-set_scheme_id]
= xref:boost/urls/url_base/set_scheme_id.adoc[boost::urls::url&lowbar;base::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_base.hpp#L281[boost&sol;url&sol;url&lowbar;base&period;hpp]&gt;`

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

== Exceptions

[cols=2]
|===
| Name
| Thrown on
| `system&lowbar;error`
| The scheme is invalid&period;
|===

== Return Value

`&ast;this`

== Parameters

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


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