thrust
thrust::placeholders Namespace Reference

Facilities for constructing simple functions inline. More...

## Variables

static const thrust::detail::functional::placeholder< 0 >::type _1

static const thrust::detail::functional::placeholder< 1 >::type _2

static const thrust::detail::functional::placeholder< 2 >::type _3

static const thrust::detail::functional::placeholder< 3 >::type _4

static const thrust::detail::functional::placeholder< 4 >::type _5

static const thrust::detail::functional::placeholder< 5 >::type _6

static const thrust::detail::functional::placeholder< 6 >::type _7

static const thrust::detail::functional::placeholder< 7 >::type _8

static const thrust::detail::functional::placeholder< 8 >::type _9

static const thrust::detail::functional::placeholder< 9 >::type _10

## Detailed Description

Facilities for constructing simple functions inline.

Objects in the `thrust::placeholders` namespace may be used to create simple arithmetic functions inline in an algorithm invocation. Combining placeholders such as `_1` and `_2` with arithmetic operations such as `+` creates an unnamed function object which applies the operation to their arguments.

The type of placeholder objects is implementation-defined.

The following code snippet demonstrates how to use the placeholders `_1` and `_2` with `thrust::transform` to implement the SAXPY computation:

int main()
{
x[0] = 1;
x[1] = 2;
x[2] = 3;
x[3] = 4;
y[0] = 1;
y[1] = 1;
y[2] = 1;
y[3] = 1;
float a = 2.0f;
using namespace thrust::placeholders;
thrust::transform(x.begin(), x.end(), y.begin(), y.begin(),
a * _1 + _2
);
// y is now {3, 5, 7, 9}
}