InputRange

These interfaces are intended to provide virtual function-based wrappers around input ranges with element type E. This is useful where a well-defined binary interface is required, such as when a DLL function or virtual function needs to accept a generic range as a parameter. Note that isInputRange and friends check for conformance to structural interfaces not for implementation of these interface types.

Limitations:

These interfaces are not capable of forwarding ref access to elements.

Infiniteness of the wrapped range is not propagated.

Length is not propagated in the case of non-random access ranges.

Members

Functions

moveFront
E moveFront()
opApply
int opApply(int delegate(size_t, E) )

foreach iteration uses opApply, since one delegate call per loop iteration is faster than three virtual function calls.

opApply
int opApply(int delegate(E) )

foreach iteration uses opApply, since one delegate call per loop iteration is faster than three virtual function calls.

popFront
void popFront()

Properties

empty
bool empty [@property getter]
front
E front [@property getter]

Examples

1 import std.algorithm.iteration : map;
2 import std.range : iota;
3 
4 void useRange(InputRange!int range) {
5     // Function body.
6 }
7 
8 // Create a range type.
9 auto squares = map!"a * a"(iota(10));
10 
11 // Wrap it in an interface.
12 auto squaresWrapped = inputRangeObject(squares);
13 
14 // Use it.
15 useRange(squaresWrapped);

See Also

Meta

Suggestion Box / Bug Report