On Wednesday, 22 April 2020 at 12:04:30 UTC, Manu wrote:
> This DIP single-handedly fixes compile-time issues in programs
> I've written by reducing template instantiations by near-100%,
> in particular, the expensive ones; recursive instantiations,
> usually implementing some form of static map.
>
> We should have done this a long time ago.
This is beautiful and awesome (syntax and all).
I was wondering if there's any way to to do a cross product with
this, like fun(Xs, Ys)... expand to fun(Xs[0], Ys[0]), fun(Xs[0],
Ys[1]), fun(Xs[1], Ys[0]), fun(Xs[1], Ys[1]), but that might very
well be rare enough to not warrant special consideration.
You can do this by expanding tuples with the appropriate indices:
fun(Xs[CrossIndexX], Ys[CrossIndexY])...
Where
CrossIndexX
is (0, 0, 1, 1) and
CrossIndexY is (0, 1, 0, 1).
The other thing that worries me a little is the difference
between Foo!(AliasSeq!(1,2))... and Foo!(Numbers)... - would
Foo!(AliasSeq!(1,2)...)... do the same as Foo!(Numbers)...?
This needs to be clarified in the DIP; the AliasSeq!() instantiation there is NOT actually a tuple (yet). It's just a template instantiation expression.
So, Foo!(AliasSeq!(1,2)...)... does nothing; there's no tuple in the expression to expand.
If you want to expand that AliasSeq, you need the second expression you wrote:
alias Numbers =
AliasSeq!(1,2);
Foo!(Numbers)...
So the answer is no, they are not the same.