From 1a8d4f6fe19f15f5b84995f7394533b9a0a65c9b Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 18 Mar 2017 10:48:13 +0000 Subject: [PATCH] Add changelog entry --- changelog/std-format-formattedWrite.dd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 changelog/std-format-formattedWrite.dd 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 +} +-------