How are delegate attributes in fn signature inferred?

2022-05-23 Thread wjoe via Digitalmars-d-learn
Hello, Consider this example: ```d module foo; import std.stdio; import std.algorithm; import std.traits; import std.range; void print(R)(R r) { static assert(isIterable!R); r.each!writeln; } auto construct(R)(R r, ElementType!R delegate(ulong i) fn) { static assert(isIterable!R && hasAs

Re: How are delegate attributes in fn signature inferred?

2022-05-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 May 2022 at 13:44:53 UTC, wjoe wrote: i.construct((ulong i) {return cast(int)(i+i);}).print; You can actually make this work with `construct!(int[])` rather than plain `construct`. This is a (really annoying) deficiency in dmd's implementation. (that sdc solved btw proving it

Re: How are delegate attributes in fn signature inferred?

2022-05-23 Thread wjoe via Digitalmars-d-learn
On Monday, 23 May 2022 at 13:53:02 UTC, Adam D Ruppe wrote: On Monday, 23 May 2022 at 13:44:53 UTC, wjoe wrote: [...] You can actually make this work with `construct!(int[])` rather than plain `construct`. This is a (really annoying) deficiency in dmd's implementation. (that sdc solved btw