[#boost-urls-params_encoded_ref-replace-0f]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_encoded_ref.adoc[params&lowbar;encoded&lowbar;ref]::replace
:relfileprefix: ../../../
:mrdocs:

Replace params

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/params_encoded_base/iterator.adoc[iterator]
replace(
    xref:boost/urls/params_encoded_base/iterator.adoc[iterator] pos,
    xref:boost/urls/param_pct_view.adoc[param&lowbar;pct&lowbar;view] const& p);
----

== Description

This function replaces the contents of the element at `pos` with the specified param&period;

All iterators that are equal to `pos` or come after are invalidated&period;

[NOTE]
====
The strings passed in must not come from the element being replaced, or else the behavior is undefined&period;

====

== Example

[,cpp]
----
url u( "?first=John&last=Doe" );

u.encoded_params().replace( u.encoded_params().begin(), { "title", "Mr" });

assert( u.encoded_query() == "title=Mr&last=Doe" );
----
== 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; Exceptions thrown on invalid input&period;

== Exceptions

[cols=2]
|===
| Name
| Thrown on
| `system&lowbar;error`
| `p` contains an invalid percent&hyphen;encoding&period;
|===

== Return Value

An iterator to the element&period;

== Parameters

[cols=2]
|===
| Name
| Description
| *pos*
| An iterator to the element&period;
| *p*
| The param to assign&period;
|===


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