splitter overload with terminator predicate requires forward range

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 14 16:19:02 PST 2015


On 12/14/2015 05:06 AM, Luís Marques wrote:
> The documentation for one of the overloads of std.algorithm.splitter
> claims to require an input range in the Parameters section, and a
> forward range in the function signature (template constraint) section:
>
>      auto splitter(alias isTerminator, Range)(Range input) if
> (isForwardRange!Range && is(typeof(unaryFun!isTerminator(input.front))));
>
>      Parameters:
>      isTerminator    The predicate for deciding where to split the range.
>      Range input    The input range to be split.
>
>      Returns:
>      An input range of the subranges of elements between separators. If
> input is a forward range or bidirectional range, the returned range will
> be likewise
>
> Is this a documentation bug? In any case, I would like to use this
> variant of splitter (a range and a predicate), but I only have an input
> range (because of `tee`) and the template constraint rejects that, so
> changing that requirement would be nice.

That overload uses SplitterResult

 
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm/iteration.d#L3482

which currently does require a forward range:

 
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm/iteration.d#L3608

Ali



More information about the Digitalmars-d mailing list