a variadic list of arguments to be formatted
character type of fmt
a variadic list of types of the arguments
The formatted string.
A FormatException if formatting did not succeed.
assert(format("Here are %d %s.", 3, "apples") == "Here are 3 apples."); assert("Increase: %7.2f %%".format(17.4285) == "Increase: 17.43 %");
The format string can be checked at compile-time:
auto s = format!"%s is %s"("Pi", 3.14); assert(s == "Pi is 3.14"); // This line doesn't compile, because 3.14 cannot be formatted with %d: // s = format!"%s is %d"("Pi", 3.14);
sformat for a variant, that tries to avoid garbage collection.
Converts its arguments according to a format string into a string.
The second version of format takes the format string as template argument. In this case, it is checked for consistency at compile-time and produces slightly faster code, because the length of the output buffer can be estimated in advance.