www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - splitter overload with terminator predicate requires forward range

reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
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.
Dec 14 2015
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Dec 14 2015