...

/

ElementType and Other Range Templates

ElementType and Other Range Templates

Learn the use of the ElementType range and get an overview of other range templates.

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 ...