Re: array of functions/delegates

2019-12-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/24/19 8:52 AM, MoonlightSentinel wrote: On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: 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] = [, ] } What I got: Error:

Re: array of functions/delegates

2019-12-24 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 13:13:12 UTC, MoonlightSentinel wrote: On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: 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] = [, ] } What I got: Error: non-constant expression '' Tried also with

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 13:13:12 UTC, MoonlightSentinel wrote: On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not

Re: array of functions/delegates

2019-12-24 Thread MoonlightSentinel via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 10:40:16 UTC, Mike Parker wrote: struct S {} void f1(S s) {} void f2(S s) {} alias Func = immutable(void function()); immutable Func[2] funcs = [cast(Func), cast(Func)]; Though, it's not clear to me wy the one requires casting the pointer type and the other

Re: array of functions/delegates

2019-12-24 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: 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] = [, ] } What I got: Error: non-constant expression '' Tried also with

Re: array of functions/delegates

2019-12-24 Thread Alex via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: 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] = [, ] } What I got: Error: non-constant expression '' Tried also with

array of functions/delegates

2019-12-23 Thread Rumbu via Digitalmars-d-learn
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] = [, ] } What I got: Error: non-constant expression '' Tried also with delegates (since I am in a struct context but I got: no `this` to