swap

Exchanges the values of a and b.

$(D_PSYMBOL swap) moves the contents of a and b without calling its postblits or destructors.

@trusted
void
swap
(
T
)
(
ref T a
,
ref T b
)

Parameters

a T

The first object.

b T

The second object.

Examples

int a = 3, b = 5;
swap(a, b);
assert(a == 5);
assert(b == 3);

Meta