thrust::bit_xor
Defined in thrust/functional.h
-
template<typename T = void>
struct bit_xor : public cuda::std::bit_xor<void> bit_xor
is a function object. Specifically, it is an Adaptable Binary Function. Iff
is an object of classbit_and<T>
, andx
andy
are objects of classT
, thenf(x,y)
returnsx^y
.The following code snippet demonstrates how to use
bit_xor
to take the bitwise XOR of one device_vector ofints
by another.#include <thrust/device_vector.h> #include <thrust/functional.h> #include <thrust/sequence.h> #include <thrust/fill.h> #include <thrust/transform.h> ... const int N = 1000; thrust::device_vector<int> V1(N); thrust::device_vector<int> V2(N); thrust::device_vector<int> V3(N); thrust::sequence(V1.begin(), V1.end(), 1); thrust::fill(V2.begin(), V2.end(), 13); thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), thrust::bit_xor<int>()); // V3 is now {1^13, 2^13, 3^13, ..., 1000^13}
See also
- Template Parameters
T – is a model of Assignable, and if
x
andy
are objects of typeT
, thenx^y
must be defined and must have a return type that is convertible toT
.