Fix issue #3817
This commit is contained in:
parent
0147e08225
commit
b089024313
@ -773,6 +773,12 @@ template <typename Char> class basic_format_parse_context {
|
||||
do_check_arg_id(id);
|
||||
}
|
||||
FMT_CONSTEXPR void check_arg_id(basic_string_view<Char>) {}
|
||||
FMT_CONSTEXPR void increment_next_id_if_match(int id) {
|
||||
if (next_arg_id_ == id) {
|
||||
// Skip named args.
|
||||
next_arg_id_++;
|
||||
}
|
||||
}
|
||||
FMT_CONSTEXPR void check_dynamic_spec(int arg_id);
|
||||
};
|
||||
|
||||
|
||||
@ -4269,6 +4269,7 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
|
||||
FMT_CONSTEXPR auto on_arg_id(basic_string_view<Char> id) -> int {
|
||||
int arg_id = context.arg_id(id);
|
||||
if (arg_id < 0) report_error("argument not found");
|
||||
parse_context.increment_next_id_if_match(arg_id);
|
||||
return arg_id;
|
||||
}
|
||||
|
||||
|
||||
@ -110,6 +110,15 @@ TEST(args_test, named_arg_by_ref) {
|
||||
EXPECT_EQ(fmt::vformat("{band}", store), "Rolling Scones");
|
||||
}
|
||||
|
||||
TEST(args_test, named_with_unnamed) {
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(1);
|
||||
store.push_back(fmt::arg("a1", 2));
|
||||
store.push_back(fmt::arg("a2", 3));
|
||||
store.push_back(4);
|
||||
EXPECT_EQ("1 2 3 4", fmt::vformat("{} {a1} {a2} {}", store));
|
||||
}
|
||||
|
||||
TEST(args_test, named_custom_format) {
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
auto c = custom_type();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user