December 14, 2015 splitter overload with terminator predicate requires forward range | ||||
|---|---|---|---|---|
| ||||
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.
| ||||
December 14, 2015 Re: splitter overload with terminator predicate requires forward range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply