This is SO crazy. D has variable template args!

BCS ao at
Thu Jul 12 11:42:00 PDT 2007

Reply to Craig,

> I agree with most that the use of << and >> or other forms of operator
> overloading are inappropriate to process variable number of arguments.
> D has variable template args built in to the freakin language.  It's
> typesafe, elegant, and straightforward.
> // C++ yuck
> cout << "x is " << x << endl;
> // Tango yuck
> Stdout("x is ")(x).newline;
> // Would be best and very easy to implement
> write("x is ", x, newline);
> -Craig

how about:

alias Teritef!("this is the format %B %xL %eR\n") myWrite; // args == (bool, 
long, real) output = (T/F, hex, exponent)

My only issue is that it needs to be some sort of wrapper or huge code bloat 
will be a problem.

More information about the Digitalmars-d-learn mailing list