Re: Parameter pack expansion

2019-05-30 Thread Tomas via Digitalmars-d-learn
On Thursday, 30 May 2019 at 20:55:00 UTC, Q. Schroll wrote: If it would be implemented, you could place your parameter pack into a Tuple-like structure with an opDispatch that returns such a Tuple again, but the contents would be the member components "projection" to the member. It's doable[2],

Re: Parameter pack expansion

2019-05-30 Thread Tomas via Digitalmars-d-learn
On Thursday, 30 May 2019 at 20:34:18 UTC, Adam D. Ruppe wrote: Foo foo; test(foo.tupleof); // works! This is really neat! I will definitely use this in the future. import std.meta; then staticMap is like what your myMap thing was. http://dpldocs.info/experimental-docs/std.meta.staticMap.htm

Re: Parameter pack expansion

2019-05-30 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 30 May 2019 at 20:20:47 UTC, Tomas wrote: I'm very new to D, coming from C++ I'm missing parameter pack expansion and fold expressions. I also miss the expansion operator and fold expressions. In D, there is no such thing, and simulating it in a general way has so muc

Re: Parameter pack expansion

2019-05-30 Thread ag0aep6g via Digitalmars-d-learn
On 30.05.19 22:20, Tomas wrote: Surely, there has to be a standard function which does exactly(probably better) the same thing as what `myMap` does. Nope.

Re: Parameter pack expansion

2019-05-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 May 2019 at 20:20:47 UTC, Tomas wrote: How do I do something like this in D? D's built-in tuples expand automatically when they are used. Library tuples (from phobos std.typecons) have a `.expand` method you can use. Fun fact: all structs also have a `.tupleof` thing that yi

Parameter pack expansion

2019-05-30 Thread Tomas via Digitalmars-d-learn
I'm very new to D, coming from C++ I'm missing parameter pack expansion and fold expressions. For example, I want to write a function `f(x[0], ..., x[n])` which accepts any number of objects and calls `g(x[0].member, ..., x[n].member)`. In C++, I would write this: template