Thanks! The alias solution works and is good enough for me. Also
thanks for providing the code to typecheck the alias, I would
have never been able to come up with that myself.
On Saturday, 20 February 2021 at 09:16:46 UTC, Simon van Bernem
wrote:
I have the following struct declaration:
struct Hash_Table(Key, Value, u32 delegate(ref Key)
custom_hash_function = null)
[snip]
I take it from the error that the problem is not actually the
delegate that I am passing, but
I have the following struct declaration:
struct Hash_Table(Key, Value, u32 delegate(ref Key)
custom_hash_function = null){
...
}
When I try to instance the Type like this:
Hash_Table!(Component*, Component_Tick_Info, (c) =>
hash32(c.handle.bitfield)) my_hash_table;
I get the followin
10.01.2011 21:08, Mitja пишет:
Thanks, toDelegate is what I've been looking for.
It still segfaults, though.
The setup:
===
module mod1;
import std.algorithm;
import std.functional;
import std.stdio;
void main( ) {
auto haystack = ["a","b","c"];
auto needle = "b";
auto flt = de
d is D 2.051.
As well as on Windows XP as guest OS in VirtualBox.
XP prints out: "object.Error: Access Violation"
>
> > It works fine when packages in mod2 are omitted.
>
> When which packages in mod2 are omitted?
>
> I can only make out that this is a compiler bug
to result = filter!dg(haystack);
>writeln(result);
> }
>
> I would have to argue that the delegate is hardly templated, though. Not
> sure what that means.
>
> > What would be the correct way for templated delegate?
>
> Depending on what you mean by &
= "b";
auto flt = (string s){return s == needle;};
auto dg = toDelegate( flt );
auto result = filter!dg(haystack);
writeln(result);
}
I would have to argue that the delegate is hardly templated, though. Not
sure what that means.
What would be the correct way for templated d
t way for templated delegate?
It depends on what you're trying to do.
Stewart.
the program would produce
segmentation fault.
It works fine when packages in mod2 are omitted.
What would be the correct way for templated delegate?