mirror of
https://github.com/fmtlib/fmt.git
synced 2026-08-03 20:14:20 +02:00
Handle const-qualified named arguments
A named argument that arrives const-qualified was not recognized by is_named_arg, silently dropping its name. This happens both when a named argument is passed through an intermediate function returning const T& (https://github.com/fmtlib/fmt/issues/4866) and in fmt's own compiled format path, which passes arguments as const T&. Make is_named_arg and is_static_named_arg see through top-level const so the name is preserved instead of dropped.
This commit is contained in:
@@ -163,6 +163,10 @@ TEST(compile_test, named) {
|
||||
fmt::format(FMT_COMPILE("{a0} {a1}"), "a0"_a = 41, "a1"_a = 43));
|
||||
EXPECT_EQ("41 43",
|
||||
fmt::format(FMT_COMPILE("{a1} {a0}"), "a0"_a = 43, "a1"_a = 41));
|
||||
|
||||
// A statically-named argument with a format spec compiles to spec_field,
|
||||
// which passes the argument to make_format_args as const (#4866).
|
||||
EXPECT_EQ("4.2", fmt::format(FMT_COMPILE("{arg:3.1f}"), "arg"_a = 4.2));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user