Re: "%s"-format template function arguments

2018-04-15 Thread ag0aep6g via Digitalmars-d-learn
On 04/15/2018 02:04 PM, vladdeSV wrote:     foo(1,2,3);     void foo(T...)(T args)     {     writefln("expected: %s", [1,2,3]);     writefln("actual: %s", args);     } The code above will output     expected: [1, 2, 3]     actual: 1 How would I go on about to print all the

Re: "%s"-format template function arguments

2018-04-15 Thread Dennis via Digitalmars-d-learn
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote: How would I go on about to print all the arguments as I expected it, using "%s"? You can expand the template arguments into an array by putting it into square brackets: [args]. You can format an array with the default notation using

Re: "%s"-format template function arguments

2018-04-15 Thread Alex via Digitalmars-d-learn
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote: Hello people of D-land. In a template function, I want to format all arguments as if it was an array. Se this snippet of code: foo(1,2,3); void foo(T...)(T args) { writefln("expected: %s", [1,2,3]);