Struct thrust::unary_function

unary_function is an empty base class: it contains no member functions or member variables, but only type information. The only reason it exists is to make it more convenient to define types that are models of the concept Adaptable Unary Function. Specifically, any model of Adaptable Unary Function must define nested typedefs. Those typedefs are provided by the base class unary_function.

The following code snippet demonstrates how to construct an Adaptable Unary Function using unary_function.

struct sine : public thrust::unary_function<float,float>
{
  __host__ __device__
  float operator()(float x) { return sinf(x); }
};

Note: Because C++11 language support makes the functionality of unary_function obsolete, its use is optional if C++11 language features are enabled.

See:

#include <thrust/functional.h>
template <typename Argument,   typename Result> struct thrust::unary_function { public:   /* The type of the function object's argument. */  typedef see below argument_type;
   /* The type of the function object's result. */  typedef see below result_type; };

Member Types

Typedef thrust::unary_function::argument_type

typedef Argumentargument_type; The type of the function object’s argument.

Typedef thrust::unary_function::result_type

typedef Resultresult_type; The type of the function object’s result.