template<typename... T>
class maxon::Tuple< T >
Tuple provides in-place static storage for elements of arbitrary types. It is similar to a pair, but supports a variable number of elements. The memory layout is identical to a struct with the same member types:
Tuple<T1, T2, T3> t;
struct MyType { T1 a; T2 b; T3
c; };
MyType t;
Py_UNICODE c
Definition: unicodeobject.h:1200
Tuples allow to create generic classes which store a variable number of member-like types that can be initialized from a parameter pack. Example:
template <typename ... Ts> class MyGenericClass
{
Tuple<Ts ...> storedArgs;
MyGenericClass(Ts ...
args) : storedArgs(
args) { }
};
PyObject * args
Definition: abstract.h:159
Tuples can also reduce the amount of boilerplate code when storing struct-like entries in containers like BaseArray, because they already come with the full range of constructors, assignment operators and comparison operators defined.
Another use case is simplifying multiple return values from a function by wrapping them in a tuple and using Tie to map them to variables:
Tie(a, b,
c) = FuncThatReturnsTupleOfABC();
A
Quality A.
Definition: macros.h:1
B
Quality B.
Definition: macros.h:2
C
Quality C.
Definition: macros.h:3
auto Tie(TYPES &... args) -> Tuple< TYPES &... >
Definition: tuple.h:1177
Since tuple elements are unnamed and can only be accessed by index or unique type, when using them in interfaces you should always consider whether using a struct with named elements would make things more obvious.
- Template Parameters
-
|
| Tuple ()=default |
|
template<typename... U, typename = typename std::enable_if<And<STD_IS_REPLACEMENT(constructible, T, const U&)...>::value>::type> |
| Tuple (const Tuple< U... > &src) |
|
template<typename... U, typename = typename std::enable_if<And<STD_IS_REPLACEMENT(constructible, T, U&&)...>::value>::type> |
| Tuple (Tuple< U... > &&src) |
|
MAXON_IMPLICIT | Tuple (const typename std::conditional< COPYABLE, T, volatile DummyParamType >::type &... x) |
|
template<typename... U, typename = typename std::enable_if<And<STD_IS_REPLACEMENT(constructible, T, U&&)...>::value>::type> |
MAXON_IMPLICIT | Tuple (U &&... x) |
|
template<typename... U> |
Tuple & | operator= (const Tuple< U... > &src) |
|
template<typename... U> |
Tuple & | operator= (Tuple< U... > &&src) |
|
Result< void > | CopyFrom (const typename std::conditional< COPYABLE, DummyParamType, Tuple >::type &src) |
|
SFINAEHelper< String, T... >::type | ToString (const FormatStatement *format=nullptr) const |
|
template<typename HASH = DefaultCompare> |
HashInt | GetHashCode () const |
|
template<typename HASH = DefaultCompare> |
UniqueHash | GetUniqueHashCode () const |
|
template<Int I> |
std::add_const< typename Pack::template At< I >::type >::type & | Get () const |
|
template<Int I> |
Pack::template At< I >::type & | Get () |
|
template<typename ELEMENTTYPE > |
auto | Get () const -> const ELEMENTTYPE & |
|
template<typename ELEMENTTYPE > |
auto | Get () -> ELEMENTTYPE & |
|
Bool | operator== (const Tuple &other) const |
|
Bool | operator< (const Tuple &other) const |
|
| MAXON_OPERATOR_COMPARISON (Tuple) |
|
| TupleStorage ()=default |
|
| TupleStorage (std::index_sequence< I... > *, ARGS &&... args) |
|
| MAXON_DECLARE_CONDITIONAL_COPY_CONSTRUCTOR (TupleStorage, COPY_CONSTRUCTIBLE) |
|
| MAXON_DECLARE_CONDITIONAL_COPY_ASSIGNMENT (TupleStorage, COPY_ASSIGNABLE) |
|
| MAXON_DECLARE_CONDITIONAL_MOVE_CONSTRUCTOR (TupleStorage, MOVE_CONSTRUCTIBLE) |
|
| MAXON_DECLARE_CONDITIONAL_MOVE_ASSIGNMENT (TupleStorage, MOVE_ASSIGNABLE) |
|
| TupleStorageBase ()=delete |
|
| ~TupleStorageBase () |
|
|
template<typename... U, size_t... I> |
| Tuple (std::index_sequence< I... > *seq, const Tuple< U... > &src) |
|
template<typename... U, size_t... I> |
| Tuple (std::index_sequence< I... > *seq, Tuple< U... > &&src) |
|
template<typename... U, size_t... I> |
void | CopyAssign (std::index_sequence< I... > *, const Tuple< U... > &src) |
|
template<typename... U, size_t... I> |
void | MoveAssign (std::index_sequence< I... > *, Tuple< U... > &&src) |
|
template<size_t... I> |
Result< void > | CopyFromImpl (std::index_sequence< I... > *, const Tuple &src) |
|
template<size_t... I> |
SFINAEHelper< String, T... >::type | ToStringImpl (std::index_sequence< I... > *, const FormatStatement *format) const |
|
template<typename HASH , size_t... I> |
HashInt | GetHashCodeImpl (std::index_sequence< I... > *) const |
|
template<typename HASH , size_t... I> |
UniqueHash | GetUniqueHashCodeImpl (std::index_sequence< I... > *) const |
|
template<size_t... I> |
Bool | EqualsImpl (std::index_sequence< I... > *, const Tuple &other) const |
|
template<size_t... I> |
Bool | LessThanImpl (std::index_sequence< I... > *, const Tuple &other) const |
|