December 07
Hi,

  Request your help, on how to define N arguments, example in the below code we are stating the the function mTemplate has to receive 3 parameters so we define as "mTemplate(T1, T2, T3) (T1 Name, T2 USize, T3 ISize)", so rather than defining 3 (T1,T2,T3) would it be possible to define like (T n) meaning that the function can receive any number of parameters.

import std.stdio: writeln;
import std.typecons: tuple;

auto mTemplate(T1, T2, T3) (T1 Name, T2 USize, T3 ISize) {
return tuple (Name, USize, ISize);
}
void main () {
string Name = "Test";
ulong USize = 1024;
int ISize = 10;
writeln(mTemplate(Name, USize, ISize)[]);
}

Something similar as below:

auto mTemplate(T n) (T n) {
return tuple (N);
}
void main () {
string Name = "Test";
ulong USize = 1024;
int ISize = 10;
writeln(mTemplate(Name)[]);
writeln(mTemplate(Name, USize)[]);
writeln(mTemplate(Name, USize, ISize)[]);
}


From,
Vino.B

December 07
On Thursday, 7 December 2017 at 17:52:30 UTC, Vino wrote:

> auto mTemplate(T n) (T n) {
> return tuple (N);


auto mTemplate(T...)(T n) {
   return tuple(n);
}

see https://dlang.org/spec/template.html#variadic-templates