Re: Unpack Variadic Args?

2020-02-13 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Feb 13, 2020 at 12:32:01PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > Some syntax like expr(someTuple)... would be really cool to have in D. > > Or something like arg => expr syntax for templates might be useful: > > f(staticMap!(!a => foo(a), args)); // look ma,

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 12:24 PM, Steven Schveighoffer wrote: But this means you have an additional function call (which could of course be inlined). And I might add, an additional requirement to declare some other template (one of the huge drawbacks of std.meta, IMO). Some syntax like

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 12:18 PM, Adam D. Ruppe wrote: On Thursday, 13 February 2020 at 17:13:31 UTC, Steven Schveighoffer wrote: the f(foo(args)...) syntax doesn't have a D equivalent. It would be staticMap f(staticMap!(foo, args)) No,

Re: Unpack Variadic Args?

2020-02-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 February 2020 at 17:13:31 UTC, Steven Schveighoffer wrote: the f(foo(args)...) syntax doesn't have a D equivalent. It would be staticMap f(staticMap!(foo, args)) staticMap is a recursive template

Re: Unpack Variadic Args?

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/20 11:29 AM, Jeff wrote: On Thursday, 13 February 2020 at 08:06:52 UTC, Paul Backus wrote: Variadic template arguments unpack automatically in D, so you don't need to do anything special here:     void g(Args...)(auto ref Args args) {     import core.lifetime: forward; // like

Re: Unpack Variadic Args?

2020-02-13 Thread Jeff via Digitalmars-d-learn
On Thursday, 13 February 2020 at 08:06:52 UTC, Paul Backus wrote: On Thursday, 13 February 2020 at 07:06:49 UTC, Jeff wrote: Hello, Was wondering if there was a simple, efficient way to unpack a variadic template argument. It needs to be efficient at runtime, and hopefully not use too much

Re: Unpack Variadic Args?

2020-02-13 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 13 February 2020 at 07:06:49 UTC, Jeff wrote: Hello, Was wondering if there was a simple, efficient way to unpack a variadic template argument. It needs to be efficient at runtime, and hopefully not use too much excessive CTFE. C++ has the "..." operator, is there something

Unpack Variadic Args?

2020-02-12 Thread Jeff via Digitalmars-d-learn
Hello, Was wondering if there was a simple, efficient way to unpack a variadic template argument. It needs to be efficient at runtime, and hopefully not use too much excessive CTFE. C++ has the "..." operator, is there something equivalent in D? template void g(Args... args) {