thrust::swap
Defined in thrust/swap.h
-
template<typename Assignable1, typename Assignable2>
inline void thrust::swap(Assignable1 &a, Assignable2 &b) swap
assigns the contents ofa
tob
and the contents ofb
toa
. This is used as a primitive operation by many other algorithms.The following code snippet demonstrates how to use
swap
to swap the contents of two variables.#include <thrust/swap.h> ... int x = 1; int y = 2; thrust::swap(x,h); // x == 2, y == 1
- Parameters
a – The first value of interest. After completion, the value of b will be returned here.
b – The second value of interest. After completion, the value of a will be returned here.
- Template Parameters
Assignable – is a model of Assignable.