On Monday, 29 July 2013 at 15:02:13 UTC, Robert Clipsham wrote:
On Monday, 29 July 2013 at 14:46:02 UTC, Robert Clipsham wrote:
You can achieve this like so:
----
template Outer(T...) {
template Inner(U...) {
// Do something with T and U
}
}
Outer!(a, b, c).Inner!(d, e, f);
----
You can see an example of it in action here (type tuple
intersection):
https://github.com/mrmonday/misc/blob/master/misc/misc.d#L5
Robert
What would be more interesting would be to have the ability to
have variadic variadics, so you could use something like:
----
template Outer(T...) {
template Inner(U... ...) {
// Do something with T, U[0], U[1], U[2..$]
}
}
Outer!(a, b, c).Inner!(d, e, f).Inner!(g, h, i); // Etc
----
Of course that raises the question of variadic variadic
variadics
and variadic variadic variadic variadics and so on, and my
proposed syntax is already silly............
I don't think so, this seems similar:
It would be cool if we could nest templates to get grouping
template tIF(alias cond)
{
template tIF(alias T...)
{
template tIF(alias F...)
{
....
}
}
then do
tIF!(cond)!(t1,t2,t3)!(f1,..,fn)
which would allow for a natural grouping of variadics. The
notation may seem silly but only because it is not common.
which could have a short hand notation of
tIF!(cond; t1, t2, t3; f1, ..., fn);
(this way, if you can't keep track of your ';'s then you can use
the long form)