an output range where the formatted value is written to
the value to write
a FormatSpec defining the format specifier
the type of the output range w
the type of value val
the character type used for f
A FormatException if formatting did not succeed.
Note: In theory this function should be @nogc. But with the current implementation there are some cases where allocations occur. See $(D sformat) for more details.
import std.array : appender; import std.format.spec : singleSpec; auto writer = appender!string(); auto spec = singleSpec("%08b"); writer.formatValue(42, spec); assert(writer.data == "00101010"); spec = singleSpec("%2s"); writer.formatValue('=', spec); assert(writer.data == "00101010 ="); spec = singleSpec("%+14.6e"); writer.formatValue(42.0, spec); assert(writer.data == "00101010 = +4.200000e+01");
formattedWrite which formats several values at once.
Formats a value of any type according to a format specifier and writes the result to an output range.
More details about how types are formatted, and how the format specifier influences the outcome, can be found in the definition of a format string.