Using arrays of function pointers in D

John via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 21 09:30:58 PDT 2015


On Thursday, 21 May 2015 at 16:25:24 UTC, Adam D. Ruppe wrote:
> Start with a function type declaration:
>
> void function() func_ptr;
>
> Then make an array out of it:
>
> void function()[] func_ptr_array;
>
>
> It works like other arrays, just the [] might be a little 
> harder to see since it is a much longer type signature. But it 
> is still in there, right after it, similarly to int[].
>
> Then the array is indexed and set like normal. You can change 
> length on it (auto initializes all members to null), ~= 
> &my_func to append, etc.
>
> You can also do associative arrays of function pointers btw.

Thanks! Holy moly you guys are quick in here.


More information about the Digitalmars-d-learn mailing list