setDelegate

Sets the context and the function of a delegate.

void
setDelegate
(
T
FT
)
(
ref T t
,
void* context
,
FT code
)
if (
is(T == delegate) &&
is(FT == typeof(T.funcptr))
)

Parameters

T

The type of the delegate.

t T

The delegate to set.

context void*

The context pointer, e.g a pointer to a struct or a class instance.

code FT

The pointer to the static function.

Examples

struct Foo
{
	bool fun(){return true;}
}
Foo foo;
bool delegate() atFun;
atFun.setDelegate(&foo, &Foo.fun);
assert(atFun());

Meta