On 1/30/18 12:53 PM, cc wrote:
     import std.container;
     import std.format;
     Array!char str;
     str.length = 256;

     str.sformat!"%s:%s"("some", "string");
    // Error: template std.format.sformat cannot deduce function from argument types !("%s:%s")(Array!char, string, string), candidates are:     //   std.format.sformat(alias fmt, Args...)(char[] buf, Args args) if (isSomeString!(typeof(fmt)))     //   std.format.sformat(Char, Args...)(char[] buf, in Char[] fmt, Args args)

sformat requires a builtin array, apparently. It doesn't work for other types.


     auto rng = cast(char[]) str[];
    // Error: cannot cast expression `str.opSlice()` of type `RangeT!(Array!char)` to `char[]`

why not just auto rng = str[]?

Additionally, would sformat cause GC allocations even when writing to a preallocated buffer?

Not directly. If sformat needs to call a function on what you are asking to format that would use the GC, then it would not be @nogc.

-Steve

Reply via email to