[#BloombergLP-bdlc-BitArray-swapBits]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlc.adoc[bdlc]::xref:BloombergLP/bdlc/BitArray.adoc[BitArray]::swapBits
:relfileprefix: ../../../
:mrdocs:

Exchange the bit values at `index1` and `index2`&period;

== Synopsis

Declared in `&lt;bdlc&lowbar;bitarray&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
swapBits(
    std::size&lowbar;t index1,
    std::size&lowbar;t index2);
----

== Description

Efficiently exchange the values of the bits at the specified `index1` and `index2` indices&period; The behavior is undefined unless `index1 &lt; length()` and `index2 &lt; length()`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *index1*
| first bit position to exchange
| *index2*
| second bit position to exchange
|===


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