Template Class Tuple¶
Defined in File tuple.hpp
Class Documentation¶
-
template<typename ...
Ts
>
classripple
::
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>
constexprTuple
(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>
constexprTuple
(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.