D and Secure Programming
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 2 22:30:24 PDT 2016
On 10/2/2016 8:50 PM, Jacob wrote:
> import std.stdio;
>
> struct SomeStruct
> {
> int value;
>
> void func()
> {
> writeln(value);
> }
>
> }
>
> void main()
> {
> SomeStruct someStruct;
> someStruct.value = 333;
>
> auto func = cast(void function(ref SomeStruct))&SomeStruct.func;
>
> func(someStruct);
> }
>
> Has worked so far for me.
That's cool, but it does rely on the ABI of regular functions matching that of
member functions, which isn't true on all platforms.
More information about the Digitalmars-d
mailing list