Template Class tuple

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, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
class tuple : 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 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.
Template Parameters
  • TN: The type of the N tuple element. Thrust’s tuple 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

pair

See

get

See

make_tuple

See

tuple_element

See

tuple_size

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 this tuple'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 this tuple's first element.

  • t1: The value to assign to this tuple'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 a pair.

Parameters
  • k: A pair to assign from.

__host__ __device__ void thrust::tuple::swap(tuple & t)

swap swaps the elements of two tuples.

Parameters
  • t: The other tuple with which to swap.