iotaTuple

Returns expression tuple with elements going through the numbers begin, begin + step, begin + 2 * step, ..., up to and excluding end. The two-arguments version has step = 1. The one-argument version also has begin = 0. If begin < end && step < 0 or begin > end && step > 0 or begin == end, then an empty tuple is returned.

  1. alias iotaTuple(alias begin, alias end, alias step) = iotaTupleImpl!(CommonType!(typeof(begin), typeof(end), typeof(step)), begin, end, step)
  2. alias iotaTuple(alias begin, alias end) = iotaTupleImpl!(CommonType!(typeof(begin), typeof(end)), begin, end, 1)
    alias iotaTuple(alias begin, alias end) = iotaTupleImpl!(CommonType!(typeof(begin), typeof(end)), begin, end, 1)
  3. alias iotaTuple(alias end) = iotaTupleImpl!(typeof(end), 0, end, 1)

Examples

int res;
foreach(i; iotaTuple!5) // same as res += foo!1(); res += foo!3();
	static if(i & 1)
		res += foo!i();

Tip: This is a convenient way to create a CT analog of Foreach Range Statement.

Analog of $(STDREF range, iota) for generic tuples.

Meta