buf containing the formatted string.sformat
fn
char[] sformat(Char, Args...)(return scope char[] buf, scope const(Char)[] fmt, Args args)Converts its arguments according to a format string into a buffer. The buffer has to be large enough to hold the formatted string.
The second version of sformat takes the format string as a template argument. In this case, it is checked for consistency at compile-time.
Parameters
buf | the buffer where the formatted string should go |
fmt | a format string |
args | a variadic list of arguments to be formatted |
Char | character type of fmt |
Args | a variadic list of types of the arguments |
Returns
A slice of
Throws
A RangeError if
buf
isn't large enough to hold the formatted string and 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:
- An exception is thrown.
- A custom
toStringfunction of a compound type allocates.
fn
char[] sformat(alias fmt, Args...)(char[] buf, Args args) if (isSomeString!(typeof(fmt)))ditto