On Saturday, 15 August 2015 at 10:06:13 UTC, Joseph Rushton Wakeling wrote:
...

I had this issue recently when reading from a command-line-style TCP connection; I needed to read the line up to the \n separator, but consuming the separator meant waiting for the next byte that would never arrive unless a new command was sent.

So I made a wrapper range that evaluates the wrapped range's popFront only when front/empty is first called ("just in time"). Source code here: https://gist.github.com/ColonelThirtyTwo/0dfe76520efcda02d848

You can throw it in a UFCS chain anywhere except (for some reason) after something that takes a delegate template parameter like map. For example:

auto reader = SocketReader(socket).joiner.jitRange.map!(byt => cast(char) byt);

Reply via email to