thrust::identity

Defined in thrust/functional.h

template<typename T = void>
struct identity

identity is a Unary Function that represents the identity function: it takes a single argument x, and returns x.

The following code snippet demonstrates that identity returns its argument.

#include <thrust/functional.h>
#include <assert.h>
...
int x = 137;
thrust::identity<int> id;
assert(x == id(x));

See also

unary_function

Template Parameters

T – No requirements on T.

Public Types

typedef T argument_type

The type of the function object’s first argument.

typedef T result_type

The type of the function object’s result;.

Public Functions

inline constexpr const T &operator()(const T &x) const

Function call operator. The return value is x.