On 12/21/2012 06:01 PM, monarch_dodra wrote:
There are a lot of algorithms in std.algorithm that operate on
"foo(Range, Needles...)(Range range, Needles needles)".
Needles can be anything, in particular, either an "element" or a "range".
The thing is that every now and then, you want to save the entirety of
(the ranges) inside needles. EG, I want to be able to write:
foo(range, needles.saveAll);
I'm having trouble. I did two iterations:
//----
auto saveAll(Ranges...)(Ranges ranges) @property
{
auto ret = ranges;
foreach (Index, Type; Ranges)
static if (isForwardRange!Type)
ret[Index] = ranges[Index];
return ret;
}
//----
This doesn't work, because: Error: functions cannot return a tuple
So that's that.
...
Use a phobos tuple?
return tuple(ret)
The caller can use .expand.