getDelegate

Sets the context and the function of a new delegate.

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

Parameters

context
Type: void*

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

code
Type: FT

The pointer to the static function.

Return Value

Type: auto

A new delegate of type T.

Examples

1 struct Foo
2 {
3     bool fun(){return true;}
4 }
5 Foo foo;
6 bool delegate() atFun = getDelegate(&foo, &Foo.fun);
7 assert(atFun());

Meta