Skip to content

Commit

Permalink
Fix compile-time width/precision type check
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Aug 9, 2022
1 parent 8bd02e9 commit 7fb8d33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,10 @@ class format_string_checker {
basic_string_view<Char> format_str, ErrorHandler eh)
: context_(format_str, num_args, types_, eh),
parse_funcs_{&parse_format_specs<Args, parse_context_type>...},
types_{type_constant<Args, char>::value...} {}
types_{
mapped_type_constant<Args,
basic_format_context<Char*, Char>>::value...} {
}

FMT_CONSTEXPR void on_text(const Char*, const Char*) {}

Expand Down
1 change: 1 addition & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ TEST(format_test, runtime_width) {
fmt::format("{0:{1}}", reinterpret_cast<void*>(0xcafe), 10));
EXPECT_EQ("x ", fmt::format("{0:{1}}", 'x', 11));
EXPECT_EQ("str ", fmt::format("{0:{1}}", "str", 12));
EXPECT_EQ(fmt::format("{:{}}", 42, short(4)), " 42");
}

TEST(format_test, precision) {
Expand Down

0 comments on commit 7fb8d33

Please sign in to comment.