[#BloombergLP-bsls-AtomicOperations_ALL_ALL_ClangIntrinsics-testAndSwapInt]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/AtomicOperations_ALL_ALL_ClangIntrinsics.adoc[AtomicOperations&lowbar;ALL&lowbar;ALL&lowbar;ClangIntrinsics]::testAndSwapInt
:relfileprefix: ../../../
:mrdocs:

Conditionally swap `atomicInt` with sequential consistency&period;

== Synopsis

Declared in `&lt;bsls&lowbar;atomicoperations&lowbar;all&lowbar;all&lowbar;clangintrinsics&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
testAndSwapInt(
    xref:BloombergLP/bsls/Atomic_TypeTraits-0b/Int.adoc[AtomicTypes::Int]* atomicInt,
    int compareValue,
    int swapValue);
----

== Description

Conditionally set the value of the specified `atomicInt` to the specified `swapValue` if and only if the value of `atomicInt` equals the value of the specified `compareValue`, and return the initial value of `atomicInt`, providing the sequential consistency memory ordering guarantee&period; The whole operation is performed atomically&period;

== Return Value

initial value of `atomicInt` before the operation

== Parameters

[cols="1,4"]
|===
| Name| Description
| *atomicInt*
| atomic integer to test and possibly update
| *compareValue*
| expected current value of `atomicInt`
| *swapValue*
| value to store if the comparison succeeds
|===


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