Function to delegate conversion
Kirk McDonald
kirklin.mcdonald at gmail.com
Tue Jun 27 02:55:11 PDT 2006
BCS wrote:
> how about
>
> <code>
> int function(int, float, char[], Object) fnp = getFNP();
>
> int delegate(int, float, char[], Object) dg;
> DG* dgp = cast(DG*)cast(void*)&dg;
>
> dgp.fn = cast(void*)fnp;
> </code>
>
> It's about as type safe as ASM (a.k.a. not at all) but it should work
> cleanly (sorta).
Ah! Now that is appealing as it cuts the union out of the thing entirely.
I still need a template that can convert a function type into an
equivalent delegate type, but that previous post of mine already
outlines how that can be done. (The IsExpression can perform the reverse
operation of converting a delegate type into a function type, though I
don't believe I need that.)
-Kirk McDonald
More information about the Digitalmars-d
mailing list