ElementType and Other Range Templates
Explore how ElementType and ElementEncodingType describe range elements in D, and understand additional range templates that optimize operations like slicing and element movement.
We'll cover the following...
We'll cover the following...
ElementType and ElementEncodingType
ElementType provides the types of the elements of the range.
For example, the following template constraint includes a requirement for the element type of the first range:
void foo(I1, I2, O)(I1 input1, I2 input2, O output)
if (isInputRange!I1 &&
isForwardRange!I2 &&
isOutputRange!(O, ElementType!I1)) {
// ...
}
The previous constraint means I1 is an InputRange and I2 is a ForwardRange and O is an OutputRange that accepts the element type of I1.
Since strings are always ranges of ...