Converting function pointers to delegates

Adam D. Ruppe destructionator at gmail.com
Mon Apr 14 10:48:30 PDT 2014


On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote:
> src/yage/core/misc.d(164): Error: e2ir: cannot cast this of 
> type S to type void*


Try taking the address of this before casting it. So more like

cast(void*)&this


IIRC in D1 this was a pointer, whereas in D2 this is a reference. 
You can't cast a reference to pointer directly (at least not 
without overloading the cast operator) but you can take its 
address to fetch a pointer out of it and then work with that.

BTW see also: 
http://dlang.org/phobos/std_functional.html#toDelegate


More information about the Digitalmars-d-learn mailing list