Comment #0 by bearophile_hugs — 2012-05-30T04:59:23Z
This is an operation I'd like to do:
import std.range, std.algorithm;
void main() {
auto p = std.array.splitter("this is a message").retro();
}
DMD 2.060alpha gives:
test.d(3): Error: template std.range.retro does not match any function template declaration
...\dmd2\src\phobos\std\range.d(1292): Error: template std.range.retro(Range) if (isBidirectionalRange!(Unqual!(Range))) cannot deduce template function from argument types !()(Result)
I think a splitter of a narrow string can be a BidirectionalRange.
Comment #1 by monarchdodra — 2012-10-22T02:40:24Z
(In reply to comment #0)
> This is an operation I'd like to do:
>
> import std.range, std.algorithm;
> void main() {
> auto p = std.array.splitter("this is a message").retro();
> }
>
>
> DMD 2.060alpha gives:
>
> test.d(3): Error: template std.range.retro does not match any function template
> declaration
> ...\dmd2\src\phobos\std\range.d(1292): Error: template std.range.retro(Range)
> if (isBidirectionalRange!(Unqual!(Range))) cannot deduce template function from
> argument types !()(Result)
>
>
> I think a splitter of a narrow string can be a BidirectionalRange.
I'll take this.
Comment #2 by jack — 2015-12-21T18:04:20Z
Currently, this can be achieved via
auto p = std.array.splitter("this is a message", " ").retro();
but it's deprecated and going to be removed at the end of the month. So I don't think adding this feature to the string specific overload of splitter is going to be welcome because it looks like doing it is buggy (I assume, why else would this be deprecated?). Therefore, I think that this should be marked as won't fix.
Comment #3 by jack — 2015-12-21T18:08:47Z
(In reply to Jack Stouffer from comment #2)
> Currently, this can be achieved via
>
> auto p = std.array.splitter("this is a message", " ").retro();
>
> but it's deprecated and going to be removed at the end of the month. So I
> don't think adding this feature to the string specific overload of splitter
> is going to be welcome because it looks like doing it is buggy (I assume,
> why else would this be deprecated?). Therefore, I think that this should be
> marked as won't fix.
Wait, my mistake. Doing
auto p = std.array.splitter("this is a message", ' ').retro();
instead is perfectly fine. The string specific overload can be changed to use the first overload of splitter internally.
Argh from https://github.com/dlang/phobos/pull/6150
> Making splitter a bidirectional range fundamentally broken - at least if the delimiter has more than one element. Think about something like
If someone ever runs into this problem, you can of course always apply retro before:
[1, 2, 3].retro.splitter("this is a message")
Comment #6 by github-bugzilla — 2018-02-11T01:36:52Z