[Issue 1541] std.bind is broken?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 3 04:57:26 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1541
------- Comment #1 from rayerd.wiz at gmail.com 2007-10-03 06:57 -------
Hi.
I propose to apply a patch to "dmd\src\phobos\std\bind.d" file for this
problem.
--- bind.d Wed Oct 03 20:39:18 2007
+++ ~bind.d Wed Oct 03 20:38:20 2007
@@ -263,7 +263,7 @@
}
- string toString() {
+ char[] toString() {
return "()";
}
}
@@ -657,7 +657,7 @@
bind(&foo, tuple(23, 45))
---
*/
-typeof(new BoundFunc!(FT, EmptySlot, Tuple!(ArgList))) bind(FT, ArgList...)(FT
fp, ArgList args) {
+typeof(new BoundFunc!(FT, NullAlias, Tuple!(ArgList))) bind(FT, ArgList...)(FT
fp, ArgList args) {
auto res = new DerefFunc!(ReturnType!(bind));
res.fp = fp;
extractBoundArgs!(0, 0, ArgList)(res.boundArgs, args);
========= main.d for experimental code
import std.stdio, std.bind;
void main()
{
writefln("-less");
bool less(int a, int b){return a<b;}
auto less5 = bind(&less, _0, 5);
foreach (i; 0..7)
{
writefln(i, "<5 ", less5(i));
}
writefln("-greater");
auto greater = bind(&less, _1, _0);
auto greater3 = bind(greater.ptr, _0, 3);
foreach (i; 0..7)
{
writefln(i, ">3 ", greater3(i));
}
}
=============
>dmd main
C:\D\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
>main
-less
0<5 true
1<5 true
2<5 true
3<5 true
4<5 true
5<5 false
6<5 false
-greater
0>3 false
1>3 false
2>3 false
3>3 false
4>3 true
5>3 true
6>3 true
--
More information about the Digitalmars-d-bugs
mailing list