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] = [&f1, &f2]
}
What I go
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)&f1, cast(Func)&f2];
Though, it's n
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] = [&f1, &f2]
}
What I got: Error: non-constant expression '&am
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)&f1, cast(Func)&f2];
Though, it's n
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)&f1, cast(Func)&f2];
Though, it's not clear to me wy the one requires casting the
pointer type and the oth
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] = [&f1, &f2]
}
What I got: Error: non-constant expression '&am
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] = [&f1, &f2]
}
What I got: Error: non-constant expression '&am
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
Jarrett Billingsley wrote
It can't evaluate &func at compile-time because there is no way to
create a delegate at compile-time.
I believe that LDC used to support this, but had to remove the
functionality due to some bugs with it/to be compatible with dmd.
Jarrett Billingsley schrieb:
On Thu, Jun 4, 2009 at 12:42 PM, Trass3r wrote:
I tried to use a function lookup table to quickly access a particular one.
But the compiler (dmd1) complains about
Error: non-constant expression & func
I guess because it's used inside a class since &func is of type
On Thu, Jun 4, 2009 at 12:42 PM, Trass3r wrote:
> I tried to use a function lookup table to quickly access a particular one.
> But the compiler (dmd1) complains about
> Error: non-constant expression & func
>
> I guess because it's used inside a class since &func is of type function,
> not delegat
I tried to use a function lookup table to quickly access a particular one.
But the compiler (dmd1) complains about
Error: non-constant expression & func
I guess because it's used inside a class since &func is of type
function, not delegate?
Here's a stripped down example:
protected Object fu
12 matches
Mail list logo