thrust::tuple

Defined in thrust/tuple.h

template<class ...Ts>
using thrust::tuple = _CUDA_VSTD::tuple<T...>

tuple is a heterogeneous, fixed-size collection of values. An instantiation of tuple with two arguments is similar to an instantiation of pair with the same two arguments. Individual elements of a tuple may be accessed with the get function.

The following code snippet demonstrates how to create a new tuple object and inspect and modify the value of its elements.

#include <thrust/tuple.h>
#include <iostream>

int main() {
  // Create a tuple containing an `int`, a `float`, and a string.
  thrust::tuple<int, float, const char*> t(13, 0.1f, "thrust");

  // Individual members are accessed with the free function `get`.
  std::cout << "The first element's value is " << thrust::get<0>(t) << std::endl;

  // ... or the member function `get`.
  std::cout << "The second element's value is " << t.get<1>() << std::endl;

  // We can also modify elements with the same function.
  thrust::get<0>(t) += 10;
}

See also

Pair

See also

get

See also

make_tuple

See also

tuple_element

See also

tuple_size

See also

tie

Template Parameters

Ts – The type of the N tuple element. Thrust’s tuple type currently supports up to ten elements.