Variadic templates
Oskar Linde
olREM at OVEnada.kth.se
Thu Nov 2 02:31:16 PST 2006
Walter Bright wrote:
> See http://www.digitalmars.com/d/variadic-function-templates.html
>
> Why now? Because it's such a pain to do template programming without
> them, and because I wanted to have a good signals and slots
> implementation. That was the last piece needed to make S&S work right
> (unless I'm way off track with it).
This looks excellent. Supporting both a head-tail recursive variant and the
indexable/foreachable tuple is brilliant. This will tremendously simplify
much of my code and remove the hard limits on number of arguments.
I also wish dmd gets better at inlining long chains of recursive template
functions.
> There's a lot of unexplored territory with the tuples, they should be
> able to do a lot more than the current rather limited ability.
I am really excited about the possibilities here. Will tuples become real
types or a meta-types?
>From the examples you show, I'd presume there is an implicit tuple expansion
when calling
void foo(int a, int b) {}
as foo(t); where t is a tuple of (int,int) ?
will it be possible to declare a function such as taking a specific tuple
argument and use tuples as return values etc?
As I said, I think this looks great. We are no longer in the vicinity of D
1.0... We are already at 2.0 :)
/Oskar
More information about the Digitalmars-d
mailing list