TransverseOptions

Options for the FrontTransversal and Transversal ranges (below).

Values

ValueMeaning
assumeJagged

When transversed, the elements of a range of ranges are assumed to have different lengths (e.g. a jagged array).

enforceNotJagged

The transversal enforces that the elements of a range of ranges have all the same length (e.g. an array of arrays, all having the same length). Checking is done once upon construction of the transversal range.

assumeNotJagged

The transversal assumes, without verifying, that the elements of a range of ranges have all the same length. This option is useful if checking was already done from the outside of the range.

Examples

import std.algorithm.comparison : equal;
import std.exception : assertThrown;

auto arr = [[1, 2], [3, 4, 5]];

auto r1 = arr.frontTransversal!(TransverseOptions.assumeJagged);
assert(r1.equal([1, 3]));

// throws on construction
assertThrown!Exception(arr.frontTransversal!(TransverseOptions.enforceNotJagged));

auto r2 = arr.frontTransversal!(TransverseOptions.assumeNotJagged);
assert(r2.equal([1, 3]));

// either assuming or checking for equal lengths makes
// the result a random access range
assert(r2[0] == 1);
static assert(!__traits(compiles, r1[0]));

Meta