Variadic templates
Sean Kelly
sean at f4.ca
Thu Nov 2 09:39:49 PST 2006
Lionello Lunesu wrote:
> 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).
>>
>> 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'm glad you could get that to work!
>
> But why not force "static" before the "foreach"?
Because 'a' is a run-time construct. It's a bit weird, but think of
tuples (ie. variadric templates) like static arrays. You know their
length and element types at compile-time and so can use static if, etc,
for processing some bits then. But they are also a run-time construct
in that actual data is being passed around, so iterating across the data
uses foreach. That said, it would be kind of nice to have static
foreach work on the contents of static arrays, tuples containing
constants, type lists, etc. This could make creating factory classes
extremely simple.
Sean
More information about the Digitalmars-d
mailing list