D-Programming-Language/phobos — pull request #777 by monarchdodra (2012-09-07 17:22:32+00:00)
Title: Optional pass by value for formattedRead

![D2 test results for 764](https://dtestbadge.appspot.com/phobos/777.png)

Per http://forum.dlang.org/thread/fvcjygswtrfxqtffmdef@forum.dlang.org

This gives an non-pass-by-ref overload to formattedRead, so that it can take r-value arguments.

The goal is to allow calls to formatted read directly from save'd ranges, or from the output of other functions, without forcing the developer to storing them in a named (dummy) temporary (groan).

This change, AFAIK, should have zero impact on existing code.

The example code was added upon, as well as duplicated in a unittest to validate documentation.

PS: The approach to using an overload *should* be superior to using "auto-ref", as it doesn't duplicate the compiled payload of the main template.