Bug 19238 – no-arg splitter should work on ranges of characters

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-09-10T14:04:55Z
Last change time
2018-10-19T13:51:00Z
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2018-09-10T14:04:55Z
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]);
Comment #1 by github-bugzilla — 2018-10-19T13:50:59Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/f7154ec86a21029d16784c698d152ed33ef16dd4 Fix issue 19238 - Allow splitter on random-access ranges of characters that aren't character arrays.