www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19238] New: no-arg splitter should work on ranges of characters


          Issue ID: 19238
           Summary: no-arg splitter should work on ranges of characters
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: schveiguy yahoo.com

Currently, std.algorithm.iteration.splitter has an overload that works just
with character arrays and takes no parameters. This special overload is
different from the other versions of splitter in that:

1. it only works with *arrays* of characters
2. the inferred separator is any run of whitespace, as opposed to the other
splitter overloads where the separator is a fixed length.

It's currently impossible to use the other overloads of splitter to mimic this
behavior with a non-array range, such as byCodeUnit.

However, there's nothing inherently special about character arrays that makes
it incorrect to use on arbitrary code unit ranges.

In other words, this should compile:

auto range = "hello    world".byCodeUnit.splitter;
static assert(is(typeof(range.front()) == typeof("hello".byCodeUnit()));
assert(range.equals(["hello".byCodeUnit, "world".byCodeUnit]);

Sep 10 2018