D-Programming-Language/phobos — pull request #1348 by irritate (2013-06-15 20:01:56+00:00)
Title: Issue 9882 - Implement a "tee" style InputRange so that a function can be called during a chain of InputRanges.

Adds a TeeRange struct, and a tee template for creating the range as part of a chain of InputRanges.

This implements part of the requested enhancement behavior from Issue 9882 (http://d.puremagic.com/issues/show_bug.cgi?id=9882), to be able to insert debug writelns into a UFCS chain. Though the syntax and actual output will be slightly different than what is discussed in that issue (e.g. writelns are done on a per-element basis, instead of printing the entire range at once).

However, this solution is more generic, and can be used for other things. It's basically the "tap" part of the issue discussion, but I used the name "tee" since that is the well-known Unix name for piping behavior similar to this.