[Issue 19238] New: no-arg splitter should work on ranges of characters
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 10 14:04:55 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19238
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 at puremagic.com
Reporter: schveiguy at 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]);
--
More information about the Digitalmars-d-bugs
mailing list