On Saturday, 5 September 2015 at 02:29:05 UTC, Prudence wrote:
If I use functions instead of delegates it works.
I suppose the problem then is that the delegate can't create a
fat pointer when used in a static context. (i.e., why the
functions work)
The question is, then, Can I construct a delegate manually and
supply my own context pointer?
e.g.,
class X { }
void foo() { }
constructDelegate(&foo, new X()) // Creates a void delegate()
with context X
How would the X instance get passed in?
You could try this:
class X {}
void foo(X x) {}
auto x = new X();
auto dg = () => foo(x);