std.string.format call from varyargs

LeqxLeqx via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 1 17:49:30 PDT 2017


Hello!

How does one go about invoking a templated-variatic function such 
as std.string.format
with an array of objects?

For example:

string stringMyThing (string formatForMyThings, MyThing[] 
myThings)
{
   return format(
     formatForMyThings,
     myThings
     );
}



In executing the above, the 'format' method always interprets the 
entire array 'myThings' as the first argument to the format, and 
no arguments afterwards, resulting in 'orphaned' format 
specifiers if the array is longer than a single element. Even if 
the array is only a single element, the formatter will wrap the 
result of the element's 'toString()' method with '[' and ']'

I really don't want to write my own format parser.
Any help would be much appreciated!


Thanks!


More information about the Digitalmars-d-learn mailing list