digitalmars.D.learn - AA with class keys compared with identity instead of opEquals
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/3) Sep 27 2020 How do I defined an AA with class as key where keys are compared
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (5/8) Sep 27 2020 By looking at object.d and aaA.d of druntime, I d say you don't
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (4/8) Sep 27 2020 That's gonna be much slower. And I need key's to be checked for
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/6) Sep 27 2020 I got a good answer at
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (5/11) Sep 27 2020 Sorry I did not understand what you meant. It would be better if
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (6/10) Sep 28 2020 In the case where the AA-KeyType is a class (which is represented
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (4/8) Sep 28 2020 For D-classes this is the default. For extern(C++) classes it's
How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`?
Sep 27 2020
On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote:How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`?By looking at object.d and aaA.d of druntime, I d say you don't need to use void*. Object class has required infrastructure ready for using classes aa keys (have not tried though). Object class has both toHash and opEquals already implemented.
Sep 27 2020
On Sunday, 27 September 2020 at 18:56:15 UTC, Ferhat Kurtulmuş wrote:By looking at object.d and aaA.d of druntime, I d say you don't need to use void*. Object class has required infrastructure ready for using classes aa keys (have not tried though). Object class has both toHash and opEquals already implemented.That's gonna be much slower. And I need key's to be checked for equivalence ,not equality.
Sep 27 2020
On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote:How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`?I got a good answer at https://dlang.slack.com/archives/C1ZDHBB2S/p1601234030016700
Sep 27 2020
On Sunday, 27 September 2020 at 19:37:10 UTC, Per Nordlöw wrote:On Sunday, 27 September 2020 at 18:39:10 UTC, Per Nordlöw wrote:Sorry I did not understand what you meant. It would be better if you share the answer here. I found this also https://dlang.org/library/std/traits/key_type.html, but I dont know if it is related.How do I defined an AA with class as key where keys are compared using `is` instead of `opEquals`? Do I have to store the key as a `void*`?I got a good answer at https://dlang.slack.com/archives/C1ZDHBB2S/p1601234030016700
Sep 27 2020
On Sunday, 27 September 2020 at 19:45:07 UTC, Ferhat Kurtulmuş wrote:Sorry I did not understand what you meant. It would be better if you share the answer here. I found this also https://dlang.org/library/std/traits/key_type.html, but I dont know if it is related.In the case where the AA-KeyType is a class (which is represented as a pointer in D) I want the equality (opEquals) and the hashing (toHash) of the AA to compare and hash the pointers themselves, not the fields the classes points to.
Sep 28 2020
On Monday, 28 September 2020 at 08:26:15 UTC, Per Nordlöw wrote:In the case where the AA-KeyType is a class (which is represented as a pointer in D) I want the equality (opEquals) and the hashing (toHash) of the AA to compare and hash the pointers themselves, not the fields the classes points to.For D-classes this is the default. For extern(C++) classes it's not defined. That's why I added the struct wrapper on top of an extern(C++) class.
Sep 28 2020