asInputRange

Wraps an existing input stream as a Phobos-style input range, to make any input stream compatible with functions that take input ranges. The given stream is stored as a pointer in the underlying range implementation, so you should still manage ownership of the original stream.

import std.range.primitives : isInputRange;
import streams;

auto stream = inputStreamFor!int([1, 2, 3]);
auto range = asInputRange!int(stream);
assert(isInputRange!(typeof(range)));
asInputRange
(
E
S
)
(
ref S stream
)
if ()

Parameters

stream S

The stream to wrap.

Return Value

Type: auto

The input range.

Meta