diff --git a/changelog/std-format-formattedWrite.dd b/changelog/std-format-formattedWrite.dd new file mode 100644 index 00000000000..d79cccf3747 --- /dev/null +++ b/changelog/std-format-formattedWrite.dd @@ -0,0 +1,19 @@ +`std.format.formattedWrite` now accepts a compile-time checked format string + +$(REF formattedWrite, std, format) and related functions now have overloads to +take the format string as a compile-time argument. This allows the format +specifiers to be matched against the argument types passed. Any mismatch or +orphaned specifiers/arguments will cause a compile-time error: + +------- +import std.format; + +void main() { + auto s = format!"%s is %s"("Pi", 3.14); + assert(s == "Pi is 3.14"); + + static assert(!__traits(compiles, {s = format!"%l"();})); // missing arg + static assert(!__traits(compiles, {s = format!""(404);})); // surplus arg + static assert(!__traits(compiles, {s = format!"%d"(4.03);})); // incompatible arg +} +-------