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

using argument_type = T
using result_type = T

Public Functions

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