On Thursday, 17 July 2014 at 18:22:11 UTC, H. S. Teoh via
Digitalmars-d wrote:
Actually, I've realized that output ranges are really only
useful when
you want to store the final result. For data in mid-processing,
you
really want to be exporting an input (or higher) range interface
instead, because functions that take output ranges are not
composable.
And for storing final results, you just use std.algorithm.copy,
so
there's really no need for many functions to take an output
range at
all.
Plain algorithm ranges rarely need to allocate at all so those
are somewhat irrelevant to the topic. What I am speaking about
are variety of utility functions like this:
S detab(S)(S s, size_t tabSize = 8)
if (isSomeString!S)
this allocates result string. Proper alternative:
S detab(S)(ref S output, size_t tabSize = 8)
if (isSomeString!S);
plus
void detab(S, OR)(OR output, size_t tab_Size = 8)
if ( isSomeString!S
&& isSomeString!(ElementType!OR)
)