Bug 11013 – ignoring variable inside the predicate of findSplitBefore
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-11T14:00:25Z
Last change time
2019-11-14T20:57:21Z
Keywords
pull
Assigned to
No Owner
Creator
Mariusz GliwiĆski
Comments
Comment #0 by alienballance — 2013-09-11T14:00:25Z
I missed some functionality in std.algorithm, so i decided to use findSplitBefore for my purpose.
Here is the code:
http://dpaste.dzfl.pl/68f9ba62
Unfortunately, ignoring second variable in pred, results in compilation error like this:
/opt/compilers/dmd2/include/std/algorithm.d(4292): Error: template std.algorithm.find matches more than one template declaration, /opt/compilers/dmd2/include/std/algorithm.d(3504):find(alias pred = "a == b", R, E)(R haystack, E needle) if (isInputRange!(R) && is(typeof(binaryFun!(pred)(haystack.front, needle)) : bool)) and /opt/compilers/dmd2/include/std/algorithm.d(3555):find(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) if (isForwardRange!(R1) && isForwardRange!(R2) && is(typeof(binaryFun!(pred)(haystack.front, needle.front)) : bool) && !isRandomAccessRange!(R1))
/opt/compilers/dmd2/include/std/range.d(611): Error: static assert "Cannot put a char[] into a Appender!(string)"
/opt/compilers/dmd2/include/std/format.d(1433): instantiated from here: put!(Appender!(string), char[])
/opt/compilers/dmd2/include/std/format.d(1335): instantiated from here: formatUnsigned!(Appender!(string), char)
/opt/compilers/dmd2/include/std/format.d(1309): instantiated from here: formatIntegral!(Appender!(string), ulong, char)
/opt/compilers/dmd2/include/std/format.d(2950): ... (5 instantiations, -v to show) ...
/opt/compilers/dmd2/include/std/algorithm.d(4294): instantiated from here: tuple!(string, string)
/d682/f882.d(6): instantiated from here: findSplitBefore!("a==a", string, string)
Comment #1 by andrej.mitrovich — 2013-09-11T19:23:33Z
Please paste small code examples inline, thanks!
-----
import std.algorithm : findSplitBefore;
void main()
{
auto var = "abc";
var.findSplitBefore!q{a==a}(var);
}
-----
Comment #2 by dlang-bot — 2019-11-14T15:32:15Z
@berni44 created dlang/phobos pull request #7276 "Fix Issue 11013 - ignoring variable inside the predicate of find" fixing this issue:
- Fix Issue 11013 - ignoring variable inside the predicate of findSplitBefore
https://github.com/dlang/phobos/pull/7276
Comment #3 by dlang-bot — 2019-11-14T20:57:21Z
dlang/phobos pull request #7276 "Fix Issue 11013 - ignoring variable inside the predicate of find" was merged into master:
- 509e6578720264a73aaa3e11c391236de6bbc42b by Bernhard Seckinger:
Fix Issue 11013 - ignoring variable inside the predicate of findSplitBefore
https://github.com/dlang/phobos/pull/7276