Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Tuple

template <size_t N,   class T> struct thrust::tuple_element;
template <typename Pair> struct thrust::tuple_size;
/* 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 T0,   class T1,   class T2,   class T3,   class T4,   class T5,   class T6,   class T7,   class T8,   class T9> class thrust::tuple;
template <int N,   class HT,   class TT> __host__ __device__ access_traits< typenametuple_element< N, detail::cons< HT, TT > >::type >::non_const_type thrust::get(detail::cons< HT, TT > & t);
template <int N,   class HT,   class TT> __host__ __device__ access_traits< typenametuple_element< N, detail::cons< HT, TT > >::type >::const_type thrust::get(const detail::cons< HT, TT > & t);
template <class T0> __host__ __device__ detail::make_tuple_mapper< T0 >::type thrust::make_tuple(const T0 & t0);
template <class T0,   class T1> __host__ __device__ detail::make_tuple_mapper< T0, T1 >::type thrust::make_tuple(const T0 & t0,   const T1 & t1);
template <typename T0> __host__ __device__ tuple< T0 & > thrust::tie(T0 & t0);
template <typename T0,   typename T1> __host__ __device__ tuple< T0 &, T1 & > thrust::tie(T0 & t0,   T1 & t1);
template <typename T0,   typename T1,   typename T2,   typename T3,   typename T4,   typename T5,   typename T6,   typename T7,   typename T8,   typename T9,   typename U0,   typename U1,   typename U2,   typename U3,   typename U4,   typename U5,   typename U6,   typename U7,   typename U8,   typename U9> __host__ __device__ void thrust::swap(tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > & x,   tuple< U0, U1, U2, U3, U4, U5, U6, U7, U8, U9 > & y);

Member Classes

Struct thrust::tuple_element

Struct thrust::tuple_size

Class thrust::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.

Functions

Function thrust::get

template <int N,   class HT,   class TT> __host__ __device__ access_traits< typenametuple_element< N, detail::cons< HT, TT > >::type >::non_const_type get(detail::cons< HT, TT > & t); The get function returns a reference to a tuple element of interest.

The following code snippet demonstrates how to use get to print the value of a tuple element.

#include <thrust/tuple.h>
#include <iostream>
...
thrust::tuple<int, const char *> t(13, "thrust");

std::cout << "The 1st value of t is " << thrust::get<0>(t) << std::endl;

Template Parameters: N: The index of the element of interest.

Function Parameters: t: A reference to a tuple of interest.

Returns: A reference to t'sNth element.

See:

Function thrust::get

template <int N,   class HT,   class TT> __host__ __device__ access_traits< typenametuple_element< N, detail::cons< HT, TT > >::type >::const_type get(const detail::cons< HT, TT > & t); The get function returns a const reference to a tuple element of interest.

The following code snippet demonstrates how to use get to print the value of a tuple element.

#include <thrust/tuple.h>
#include <iostream>
...
thrust::tuple<int, const char *> t(13, "thrust");

std::cout << "The 1st value of t is " << thrust::get<0>(t) << std::endl;

Template Parameters: N: The index of the element of interest.

Function Parameters: t: A reference to a tuple of interest.

Returns: A const reference to t'sNth element.

See:

Function thrust::make_tuple

template <class T0> __host__ __device__ detail::make_tuple_mapper< T0 >::type make_tuple(const T0 & t0); This version of make_tuple creates a new tuple object from a single object.

Function Parameters: t0: The object to copy from.

Returns: A tuple object with a single member which is a copy of t0.

Function thrust::make_tuple

template <class T0,   class T1> __host__ __device__ detail::make_tuple_mapper< T0, T1 >::type make_tuple(const T0 & t0,   const T1 & t1); This version of make_tuple creates a new tuple object from two objects.

Note: make_tuple has ten variants, the rest of which are omitted here for brevity.

Function Parameters:

  • t0 The first object to copy from.
  • t1 The second object to copy from.

Returns: A tuple object with two members which are copies of t0 and t1.

Function thrust::tie

template <typename T0> __host__ __device__ tuple< T0 & > tie(T0 & t0); This version of tie creates a new tuple whose single element is a reference which refers to this function’s argument.

Function Parameters: t0: The object to reference.

Returns: A tuple object with one member which is a reference to t0.

Function thrust::tie

template <typename T0,   typename T1> __host__ __device__ tuple< T0 &, T1 & > tie(T0 & t0,   T1 & t1); This version of tie creates a new tuple of references object which refers to this function’s arguments.

Note: tie has ten variants, the rest of which are omitted here for brevity.

Function Parameters:

  • t0 The first object to reference.
  • t1 The second object to reference.

Returns: A tuple object with two members which are references to t0 and t1.

Function thrust::swap

template <typename T0,   typename T1,   typename T2,   typename T3,   typename T4,   typename T5,   typename T6,   typename T7,   typename T8,   typename T9,   typename U0,   typename U1,   typename U2,   typename U3,   typename U4,   typename U5,   typename U6,   typename U7,   typename U8,   typename U9> __host__ __device__ void swap(tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > & x,   tuple< U0, U1, U2, U3, U4, U5, U6, U7, U8, U9 > & y); swap swaps the contents of two tuples.

Function Parameters:

  • x The first tuple to swap.
  • y The second tuple to swap.