How to get a range from std.container.array for use with std.format.sformat?
cc
cc at nevernet.com
Tue Jan 30 17:53:22 UTC 2018
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)
auto rng = cast(char[]) str[];
// Error: cannot cast expression `str.opSlice()` of type
`RangeT!(Array!char)` to `char[]`
Additionally, would sformat cause GC allocations even when
writing to a preallocated buffer?
More information about the Digitalmars-d-learn
mailing list