From 3eb3aef5753b91d689b496a629b9dc5c4a7cd348 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 23 Dec 2023 08:32:36 -0800 Subject: [PATCH] Fix handling of set_debug_format --- include/fmt/format.h | 7 ++----- test/ranges-test.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index dd04a79e..6caa4f9d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -4097,13 +4097,10 @@ class format_int { template struct formatter::value>> - : private formatter, Char> { - using base = formatter, Char>; - using base::parse; - using base::set_debug_format; - + : formatter, Char> { template auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) { + using base = formatter, Char>; return base::format(format_as(value), ctx); } }; diff --git a/test/ranges-test.cc b/test/ranges-test.cc index ba5c464d..c67eed9f 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -528,3 +528,16 @@ TEST(ranges_test, container_adaptor) { EXPECT_EQ(fmt::format("{}", m), "[1, 2]"); } } + +struct tieable { + int a = 3; + double b = 0.42; +}; + +auto format_as(const tieable& t) -> std::tuple { + return std::tie(t.a, t.b); +} + +TEST(ranges_test, format_as_tie) { + EXPECT_EQ(fmt::format("{}", tieable()), "(3, 0.42)"); +}