Bug 9103 – find should work with multiple needles which are elements rather than ranges
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-02T01:12:00Z
Last change time
2015-06-09T05:15:23Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2012-12-02T01:12:50Z
This code works:
import std.algorithm;
void main()
{
string str = "hello world";
str = find(str, "h", "j", "\n");
}
This code works:
import std.algorithm;
void main()
{
string str = "hello world";
str = find(str, 'h');
}
But this code doesn't:
import std.algorithm;
void main()
{
string str = "hello world";
str = find(str, 'h', 'j', '\n');
}
Currently, if you pass multiple needles to find, they must all be ranges. startsWith and endsWith will work with a combination of elements and ranges. find should do the same. And since the overload of find which takes multiple needles uses startsWith, it's that much more ridiculous that find doesn't work with a combination of ranges and elements like startsWith and endsWith do.
Comment #1 by issues.dlang — 2012-12-02T01:57:06Z
Actually, I mistyped (obviously I needed to actually compile all of the examples). Reassigning to str doesn't work for _any_ of these, because the result is a Tuple, but if you just replace str = with auto result =, then the ones where find compiles will compile.