The definition of templates in D
Nick Sabalausky
a at a.a
Sun Mar 18 01:44:28 PDT 2012
"Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message
news:mailman.851.1332059038.4860.digitalmars-d at puremagic.com...
> On 3/18/12, Derek <ddparnell at bigpond.com> wrote:
>> What would be useful is ...
>> bar!(a, b, c); // is equivalent to
>> bar!(int, int, int).bar(a, b, c);
>
> You mean like this?
>
> template bar(T...)
> {
> void bar() { writeln(T); }
> }
>
> void main()
> {
> int a = 1, b = 2, c = 3;
> bar!(a, b, c);
> }
Shouldn't that be:
template bar(T...)
{
void bar(T args) { writeln(args); }
}
void main()
{
int a = 1, b = 2, c = 3;
bar(a, b, c);
}
Or did I misunderstand the point?
More information about the Digitalmars-d
mailing list