Template Struct bit_or¶
Defined in File functional.h
Struct Documentation¶
-
template<typename
T>
structbit_or¶ bit_oris a function object. Specifically, it is an Adaptable Binary Function. Iffis an object of classbit_and<T>, andxandyare objects of classT, thenf(x,y)returnsx|y.The following code snippet demonstrates how to use
bit_orto take the bitwise OR of one device_vector ofintsby another.- Template Parameters
T: is a model of Assignable, and ifxandyare objects of typeT, thenx|ymust be defined and must have a return type that is convertible toT.
#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_or<int>()); // V3 is now {1|13, 2|13, 3|13, ..., 1000|13}
Public Types
-
typedef
first_argument_type¶ The type of the function object’s first argument.
-
typedef
second_argument_type¶ The type of the function object’s second argument.
-
typedef
result_type¶ The type of the function object’s result;.
Public Functions
-
__host__ __device__ T thrust::bit_or::operator()(const T & lhs, const T & rhs) const Function call operator. The return value is
lhs | rhs.