[#absl-exchange]
= xref:absl.adoc[absl]::exchange
:relfileprefix: ../
:mrdocs:

Replace the value of an object and return its old value&period;

== Synopsis

Declared in `&lt;absl&sol;utility&sol;utility&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class T1,
    class T2 = T1&gt;
&lsqb;&lsqb;deprecated&rsqb;&rsqb;
constexpr
T1
exchange(
    T1& obj,
    T2&& new&lowbar;value) noexcept(&sol;&ast; see-below &ast;&sol;);
----

[WARNING]
====
https://en.cppreference.com/cpp/language/attributes/deprecated[Deprecated^]. Use of this entity is allowed but discouraged.
====
== Exception specification

This function is potentially-throwing unless `noexcept(std&colon;&colon;exchange(std&colon;&colon;declval&lt;T1 &amp;&gt;(), std&colon;&colon;declval&lt;T2&gt;()))`.

== Return Value

The previous value of `obj`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *obj*
| The object whose value is replaced&period;
| *new&lowbar;value*
| The value to assign to `obj`&period;
|===


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