Skip to content

Commit

Permalink
Fix handling of set_debug_format
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Dec 23, 2023
1 parent 56d7a8c commit 3eb3aef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 2 additions & 5 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -4097,13 +4097,10 @@ class format_int {

template <typename T, typename Char>
struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>>
: private formatter<detail::format_as_t<T>, Char> {
using base = formatter<detail::format_as_t<T>, Char>;
using base::parse;
using base::set_debug_format;

: formatter<detail::format_as_t<T>, Char> {
template <typename FormatContext>
auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) {
using base = formatter<detail::format_as_t<T>, Char>;
return base::format(format_as(value), ctx);
}
};
Expand Down
13 changes: 13 additions & 0 deletions test/ranges-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, double> {
return std::tie(t.a, t.b);
}

TEST(ranges_test, format_as_tie) {
EXPECT_EQ(fmt::format("{}", tieable()), "(3, 0.42)");
}

0 comments on commit 3eb3aef

Please sign in to comment.