function to call when delegate is called, must take exactly one void* argument which is the passed context
context pointer to forward to F when resulting delegate is called
forged delegate that can be passed to any API expecting regular `T delegate()` where T is the return type of F
static bool done = false; static void handler ( void* context ) { test!("==")(cast(size_t) context, 42); done = true; } void delegate() dg = toContextDg!(handler)(cast(void*) 42); test!("==")(cast(size_t) dg.ptr, 42); dg(); test(done);
Generates delegate that stores specified context as a delegate context pointer and, when called, forwards it to function F as a regular argument.
Intended to be used as a performance optimization hack to create no-allocation closures that only need to capture one pointer size argument.