Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
I don't think it's possible to call a vararg function whose number of arguments is only known at runtime, for the same reasons it is impossible in C [1]. Your switch statement is probably the best you can do, other than rewriting the API to not use varargs (which, depending on what the

Re: constructed variadic call

2016-05-03 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case

Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:56:59 UTC, Stefan Koch wrote: On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1:

Re: constructed variadic call

2016-05-02 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case

constructed variadic call

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case 3: foo(a[1], a[2], a[3]); break; ... }