Tuple
/*
tuple
is a class template that can be instantiated with up to ten arguments. Each template argument specifies the type of element in the tuple
. Consequently, tuples are heterogeneous, fixed-size collections 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. */template <class... T> using tuple = see below;
Types
Type Alias tuple
template <class... T> using tuple = ::cuda::std::tuple< T... >;
tuple
is a class template that can be instantiated with up to ten arguments. Each template argument specifies the type of element in the tuple
. Consequently, tuples are heterogeneous, fixed-size collections 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;
}
Template Parameters: TN
: The type of the N
tuple
element. Thrust’s tuple
type currently supports up to ten elements.
See:
- Pair
- get
- make_tuple
- tuple_element
- tuple_size
- tie