Unpack Variadic Args?

Steven Schveighoffer schveiguy at gmail.com
Thu Feb 13 17:24:25 UTC 2020


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 
> <http://dpldocs.info/experimental-docs/std.meta.staticMap.html>
> 
> f(staticMap!(foo, args))

No, this does foo!(args[0]), foo!(args[1])...).

He wants a runtime call to each arg wrapped with foo.

One could do:

auto wrapFoo(alias arg)() { return foo(arg); }

and then f(staticMap!(wrapFoo, args));

But this means you have an additional function call (which could of 
course be inlined). It is a viable solution though (tested, and it does 
work).

-Steve


More information about the Digitalmars-d-learn mailing list