getDelegate

Sets the context and the function of a new delegate.

getDelegate
(
FT
)
(
void* context
,
FT code
)
if (
is(PointerTarget!FT == function)
)

Parameters

context void*

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

code FT

The pointer to the static function.

Return Value

Type: auto

A new delegate of type T.

Examples

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

Meta