digitalmars.D.learn - help with bind
For some reason, I can't get this simple bind example to compile w/ dmd v2.046. Can anyone spot what I'm missing? --- import std.bind; import std.stdio; void g (int a, int b) { int c = a + b; } void main() { auto g1 = bind(&g, 3, 5); writeln(typeid(typeof(g1))); } --- gives me --- C:\tools\dmd2\windows\bin\..\..\src\phobos\std\traits.d(117): Error: static assert "argument has no parameters" C:\tools\dmd2\windows\bin\..\..\src\phobos\std\traits.d(102): instantiated from here: ParameterTypeTuple!(EmptySlot,void) C:\tools\dmd2\windows\bin\..\..\src\phobos\std\traits.d(113): instantiated from here: ParameterTypeTuple!(const(EmptySlot)) C:\tools\dmd2\windows\bin\..\..\src\phobos\std\bind.d(977): instantiated from here: ParameterTypeTuple!(const(EmptySlot)*) C:\tools\dmd2\windows\bin\..\..\src\phobos\std\bind.d(1003): instantiated from here: FuncReferenceParamsAsPointers_impl!(NullAlias) C:\tools\dmd2\windows\bin\..\..\src\phobos\std\bind.d(338): instantiated from here: FuncReferenceParamsAsPointers!(NullAlias) C:\tools\dmd2\windows\bin\..\..\src\phobos\std\bind.d(660): instantiated from here: BoundFunc!(void function(int a, int b),NullAlias,Tuple!(int,int)) bTest.d(12): instantiated from here: bind!(void function(int a, int b),int,int) --- Thanks, Jason
Jun 15 2010
I talked to Tom Stachowiak, who couldn't spot anything wrong with the code. I believe this is a bug in std.bind (or maybe std.traits.) Has anyone else seen this? With 2.047: ---- import std.bind; import std.stdio; void g (int a, int b) { int c = a + b; } void main() { auto g1 = bind(&g, _0, _0); writeln(typeid(typeof(g1))); } --- gives C:\tools\dmd2\windows\bin\..\..\src\phobos\std\bind.d(977): Error: template instance ParameterTypeTuple!(const(EmptySlot)*) does not match template declaration ParameterTypeTuple(dg...) if (dg.length == 1 && isCallable!(dg))
Jun 16 2010