[#boost-urls-params_ref-set-01]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_ref.adoc[params&lowbar;ref]::set
:relfileprefix: ../../../
:mrdocs:

Set a value

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/params_base/iterator.adoc[iterator]
set(
    core::string&lowbar;view key,
    core::string&lowbar;view value,
    xref:boost/urls/ignore_case_param.adoc[ignore&lowbar;case&lowbar;param] ic = &lcub;&rcub;);
----

== Description

This function performs one of two actions depending on the value of `this&hyphen;&gt;contains( key, ic )`&period;

* If key is contained in the view then one of the matching elements has its value changed to the specified value&period; The remaining elements with a matching key are erased&period; Otherwise,
* If `key` is not contained in the view, then the function apppends the param `&lcub; key, value &rcub;`&period;

All iterators are invalidated&period;

== Example

[,cpp]
----
url u( "?id=42&id=69" );

u.params().set( "id", "none" );

assert( u.params().count( "id" ) == 1 );
----
== Postconditions

[,cpp]
----
this->count( key, ic ) == 1 && this->find( key, ic )->value == value
----
== Complexity

Linear in `this&hyphen;&gt;url()&period;encoded&lowbar;query()&period;size()`&period;

== Exception Safety

Strong guarantee&period; Calls to allocate may throw&period;

== Return Value

An iterator to the appended or modified element&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| The key to match&period; By default, a case&hyphen;sensitive comparison is used&period;
| *value*
| The value to assign&period; The empty string still counts as a value&period; That is, `has&lowbar;value` for the element is true&period;
| *ic*
| An optional parameter&period; If the value xref:boost/urls/ignore_case.adoc[`ignore&lowbar;case`] is passed here, the comparison is case&hyphen;insensitive&period;
|===


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