The OpenD Programming Language

Tuple.slice

Takes a slice by-reference of this Tuple.

struct Tuple
@property ref inout @trusted
inout(Tuple!(sliceSpecs!(from, to)))
slice
(
size_t from
size_t to
)
()
if (
from <= to &&
)

Parameters

from

A size_t designating the starting position of the slice.

to

A size_t designating the ending position (exclusive) of the slice.

Return Value

Type: inout(Tuple!(sliceSpecs!(from, to)))

A new Tuple that is a slice from [from, to$(RPAREN) of the original. It has the same types and values as the range [from, to$(RPAREN) in the original.

Examples

Tuple!(int, string, float, double) a;
a[1] = "abc";
a[2] = 4.5;
auto s = a.slice!(1, 3);
static assert(is(typeof(s) == Tuple!(string, float)));
assert(s[0] == "abc" && s[1] == 4.5);

// https://issues.dlang.org/show_bug.cgi?id=15645
Tuple!(int, short, bool, double) b;
static assert(!__traits(compiles, b.slice!(2, 4)));

Meta