Shortcuts

Template Class Tuple

Class Documentation

template<typename ...Ts>
class ripple::Tuple

Specialization for a non-empty Tuple.

The Tuple type holds a fixed-size number of heterogenous types.

This implementation of a tuple is similar to std::tuple, but allows the tuple to be used on both the host and the device. We could use thrust::tuple, however, it only supports 9 types (rather than the compiler’s recursion depth limit in the case of this implementation), since it doesn’t use variadic tempates, which is also limiting.

Template Parameters
  • Ts: The types of the Tuple elements.

It also would then add an external dependency.

Having a separate implementation also allows for more functionality to be added where required.

The interface through which a tuple should be created is the make_tuple() function, i.e:

auto tuple = make_tuple(4, 3.5, "some value");

unless the tuple needs to store reference types. See the documentation for make_tuple for an example.

Note

If the tuple stores reference type, and is created on the host, then it will not work correctly on the device.

Template Parameters
  • Ts: The types of the elements in the tuple.

Public Functions

constexpr Tuple() noexcept

Performs default initialization of the tuple types.

constexpr Tuple(const Ts&... es) noexcept

Intializes the tuple with a variadic list of const ref elements.

Parameters
  • es: The elements to store in the tuple.

template<typename ...Types, non_tuple_enable_t<Types...> = 0>
constexpr Tuple(Types&&... es) noexcept

Initializes the tuple with a variadic list of forwarding reference lements.

This overload is only selcted if any of the types are not a tuple i.e this is not a copy or move constructor.

Parameters
  • es: The elements to store in the Tuple.

Template Parameters
  • Types: The types of the elements.

template<typename T, tuple_enable_t<T> = 0>
constexpr Tuple(T &&other) noexcept

Copy or move constructs the Tuple, depending on whether T is a rvalue or lvalue reference.

Note

This overload is only enable if the type T is a tuple.

Parameters
  • other: The other tuple to copy or move.

Template Parameters
  • T: The type of the other tuple.

constexpr auto size() const noexcept -> size_t

Gets the number of elements in the tuple.

Return

The number of elements in the tuple.

auto data() noexcept -> Storage&

Gets a reference to the underlying storage container which holds the elements.

Return

A reference to the data for the tuple.

auto data() const noexcept -> const Storage&

Gets a constant reference to the underlying storage container which holds the elements.

Return

A const reference to the data for the tuple.

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples