Variadic Template Pattern

FoxyBrown via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 9 14:21:03 PDT 2017


Hi, I have a proposal, wondering about your opinions.

Suppose one has a template function foo that accepts a variable 
number of parameters:

auto foo(T...)();

Suppose we actually want to have some type of order and type info 
instead:

auto foo(int, string)();

but we need a "variable" number of them such as

auto foo(int, string, int, string)();

auto foo(int, string, int, string, int, string)();

ad nausea.

We could simplify it all by allowing for a sort of pattern on the 
... for variadics:

auto food((int,string)...)();


and, this, of course, expands to what was described earlier.


Now, this can be accomplished already with the single template 
method and foreach/static if testing the type, but that seems 
like it's excessively verbose.





More information about the Digitalmars-d mailing list