:relfileprefix: ../../../ [#boost-urls-params_ref-set-01] = xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/params_ref.adoc[pass:[params_ref]]::set Set a value == Synopsis Declared in header `` [source,cpp,subs="verbatim,macros,-callouts"] ---- xref:boost/urls/params_base/iterator.adoc[iterator] set( core::string_view key, core::string_view value, xref:boost/urls/ignore_case_param.adoc[ignore_case_param] ic = = {}); ---- == Description This function performs one of two actions depending on the value of `this->contains( key, ic )`. * If key is contained in the view then one of the matching elements has its value changed to the specified value. The remaining elements with a matching key are erased. Otherwise, * If `key` is not contained in the view, then the function apppends the param `{ key, value }`. All iterators are invalidated. === 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->url().encoded_query().size()`. === Exception Safety Strong guarantee. Calls to allocate may throw. == Return Value An iterator to the appended or modified element. == Parameters |=== | Name | Description | *key* | The key to match. By default, a case-sensitive comparison is used. | *value* | The value to assign. The empty string still counts as a value. That is, `has_value` for the element is true. | *ic* | An optional parameter. If the value xref:boost/urls/ignore_case.adoc[ignore_case] is passed here, the comparison is case-insensitive. |===