Convert output range to input range
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Fri Mar 16 08:07:09 UTC 2018
On Friday, March 16, 2018 07:57:04 John Chapman via Digitalmars-d-learn
wrote:
> I need to write to a range created with outputRangeObject, then
> read from it. Is there a way to convert it to an input range?
The output range API only supports the put function. That's it. The output
range supports no way whatsoever to read data, and it has nothing to do with
the input range API. As such, an output range cannot be generically
converted into an input range, but some specific output ranges could be. For
instance, std.array.Appender is an output range, and you get a dynamic array
out of it, which would be an input range. So, if you have control over what
output range you're dealing with, the simplest would be to just use
Appender. If you don't have control over what output range you're dealing
with, then your options depend on what the type you're dealing with is, but
it won't work with fully generic code.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list