Skip to content

Commit

Permalink
Add changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Mar 18, 2017
1 parent c6a7e3e commit 1a8d4f6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions changelog/std-format-formattedWrite.dd
Original file line number Diff line number Diff line change
@@ -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
}
-------

0 comments on commit 1a8d4f6

Please sign in to comment.