diff --git a/include/fmt/format.h b/include/fmt/format.h index ee69651c..87685343 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2818,8 +2818,8 @@ struct formatter, Char> { } template - auto format(const join_view& value, FormatContext& ctx) - -> decltype(ctx.out()) { + auto format(const join_view& value, + FormatContext& ctx) const -> decltype(ctx.out()) { auto it = value.begin; auto out = ctx.out(); if (it != value.end) { diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 3d716ece..5a2a5456 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -86,7 +86,7 @@ struct fallback_formatter::value>> using formatter, Char>::parse; template - auto format(const T& value, basic_format_context& ctx) + auto format(const T& value, basic_format_context& ctx) const -> OutputIt { auto buffer = basic_memory_buffer(); format_value(buffer, value, ctx.locale()); @@ -96,7 +96,7 @@ struct fallback_formatter::value>> // DEPRECATED! template - auto format(const T& value, basic_printf_context& ctx) + auto format(const T& value, basic_printf_context& ctx) const -> OutputIt { auto buffer = basic_memory_buffer(); format_value(buffer, value, ctx.locale()); diff --git a/test/compile-test.cc b/test/compile-test.cc index 1765961b..2c156847 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -201,6 +201,11 @@ TEST(compile_test, named) { # endif } +TEST(compile_test, join) { + unsigned char data[] = {0x1, 0x2, 0xaf}; + EXPECT_EQ("0102af", fmt::format(FMT_COMPILE("{:02x}"), fmt::join(data, ""))); +} + TEST(compile_test, format_to) { char buf[8]; auto end = fmt::format_to(buf, FMT_COMPILE("{}"), 42);