Template Struct identity

Struct Documentation

template<typename T>
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.
Template Parameters
  • T: No requirements on T.

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

See

http://www.sgi.com/tech/stl/identity.html

See

unary_function

Public Types

typedef argument_type

The type of the function object’s first argument.

typedef result_type

The type of the function object’s result;.

Public Functions

__host__ __device__ const T& thrust::identity::operator()(const T & x) const

Function call operator. The return value is x.