Template Class tuple¶
Defined in File tuple.h
Inheritance Relationships¶
Base Type¶
public detail::map_tuple_to_cons::type< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >
Class Documentation¶
-
template<class
T0
, classT1
, classT2
, classT3
, classT4
, classT5
, classT6
, classT7
, classT8
, classT9
>
classtuple
: public detail::map_tuple_to_cons::type<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>¶ tuple
is a class template that can be instantiated with up to ten arguments. Each template argument specifies the type of element in thetuple
. Consequently, tuples are heterogeneous, fixed-size collections of values. An instantiation oftuple
with two arguments is similar to an instantiation ofpair
with the same two arguments. Individual elements of atuple
may be accessed with theget
function.The following code snippet demonstrates how to create a new
tuple
object and inspect and modify the value of its elements.- Template Parameters
TN
: The type of theN
tuple
element. Thrust’stuple
type currently supports up to ten elements.
#include <thrust/tuple.h> #include <iostream> ... // 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
- See
get
- See
make_tuple
- See
- See
- See
tie
Public Functions
-
__host__ __device__ thrust::tuple::tuple(void)
tuple's
no-argument constructor initializes each element.
-
__host__ __device__ thrust::tuple::tuple(typename access_traits< T0 >::parameter_type t0)
tuple's
one-argument constructor copy constructs the first element from the given parameter and intializes all other elements.- Parameters
t0
: The value to assign to thistuple's
first element.
-
__host__ __device__ thrust::tuple::tuple(typename access_traits< T0 >::parameter_type t0, typename access_traits< T1 >::parameter_type t1)
tuple's
one-argument constructor copy constructs the first two elements from the given parameters and intializes all other elements.- Note
tuple's
constructor has ten variants of this form, the rest of which are ommitted here for brevity.- Parameters
t0
: The value to assign to thistuple's
first element.t1
: The value to assign to thistuple's
second element.
-
template<class U1, class U2>__host__ __device__ tuple& thrust::tuple::operator=(const thrust::pair < U1, U2 > & k)
This assignment operator allows assigning the first two elements of this
tuple
from apair
.- Parameters
k
: Apair
to assign from.
-
__host__ __device__ void thrust::tuple::swap(tuple & t)
swap
swaps the elements of twotuple
s.- Parameters
t
: The othertuple
with which to swap.