thrust
Functions

Functions

template<typename Assignable1 , typename Assignable2 >
__host__ __device__ void thrust::swap (Assignable1 &a, Assignable2 &b)
 

Detailed Description

Function Documentation

template<typename Assignable1 , typename Assignable2 >
__host__ __device__ void thrust::swap ( Assignable1 &  a,
Assignable2 &  b 
)
inline

swap assigns the contents of a to b and the contents of b to a. This is used as a primitive operation by many other algorithms.

Parameters
aThe first value of interest. After completion, the value of b will be returned here.
bThe second value of interest. After completion, the value of a will be returned here.
Template Parameters
Assignableis a model of Assignable.

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;
// x == 2, y == 1