array of functions/delegates

Rumbu rumbu at
Tue Dec 24 07:37:02 UTC 2019

I am trying to create an array of functions inside a struct.

struct S {
   void f1() {}
   void f2() {}

   alias Func = void function();

  immutable Func[2] = [&f1, &f2]


What I got: Error: non-constant expression '&f1'

Tried also with delegates (since I am in a struct context but I 
got: no `this` to create delegate `f1`.

So, is there any way to have an array of functions without adding 
them at runtime?

More information about the Digitalmars-d-learn mailing list