std.range pipelike interface, inverting OutputStreams?

cy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 12 20:54:38 PDT 2016


Here's how to do it using context switches. There ought to be a 
way to manually pass specific state around to keep that from 
happening, but probably not since there's no interface to pause 
something writing to an OutputRange.

auto pipe(T, alias oh)()
{
	import std.concurrency: Generator, yield;
	return new Generator!T({
			struct OutputRange {
				void put(T item) {
					yield(item);
				}
			}
			oh(OutputRange());
		});
}



More information about the Digitalmars-d-learn mailing list