Storing interfaces as void[]

Imperatorn johan_forsberg_86 at hotmail.com
Fri Mar 12 18:14:12 UTC 2021


On Friday, 12 March 2021 at 17:57:06 UTC, David  Zhang wrote:
> On Friday, 12 March 2021 at 17:46:22 UTC, Imperatorn wrote:
>> On Friday, 12 March 2021 at 17:37:43 UTC, David  Zhang wrote:
>>> [...]
>>
>> Have you tried using Variant or jsvar 
>> (https://code.dlang.org/packages/arsd-official%3Ajsvar)? 🤔
>
> It doesn't appear to support interfaces, see opAssign at line 
> 682.
>
> It occurs to me that I.sizeof == 8 which is just enough for the 
> vtbl, but not enough for an implementation ptr. Maybe it's a 
> pointer to a {self, vtbl} pair? SomeClass.sizeof == 16, which 
> is enough storage for both...

Did you try Variant? Seems to work for me


More information about the Digitalmars-d-learn mailing list