Re: Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
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.

Templated delegate as template argument for structs

2021-02-20 Thread Simon van Bernem via Digitalmars-d-learn
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

Re: Does the default opEquals include padding in the comparison? If so, how can the problems that arise with C++ interoperabilty be solved?

2020-10-21 Thread Simon van Bernem via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 20:10:03 UTC, Paul Backus wrote: On Wednesday, 21 October 2020 at 19:23:43 UTC, Simon van Bernem wrote: The only explanation I can think of is that D memcmps the entire struct including the padding. Is this correct? If so, what can I do about this? Why doesn't

Does the default opEquals include padding in the comparison? If so, how can the problems that arise with C++ interoperabilty be solved?

2020-10-21 Thread Simon van Bernem via Digitalmars-d-learn
I ask this question because I chased a very very nasty bug all the way down, and I think I found the offender: I have a extern(C++) struct that contains an 8-byte integer followed by a 4-byte enum value. I came across two variables of that type, that are not equal by comparison (no opEquals