tuple

Constructs a Tuple object instantiated and initialized according to the given arguments.

template tuple(Names...)
tuple
(
Args...
)
(
Args args
)

Members

Functions

tuple
auto tuple(Args args)

Parameters

Names

An optional list of strings naming each successive field of the Tuple or a list of types that the elements are being casted to. For a list of names, each name matches up with the corresponding field given by Args. A name does not have to be provided for every field, but as the names must proceed in order, it is not possible to skip one field and name the next after it. For a list of types, there must be exactly as many types as parameters.

Examples

auto value = tuple(5, 6.7, "hello");
assert(value[0] == 5);
assert(value[1] == 6.7);
assert(value[2] == "hello");

// Field names can be provided.
auto entry = tuple!("index", "value")(4, "Hello");
assert(entry.index == 4);
assert(entry.value == "Hello");

Meta