Skip to content

Commit

Permalink
improved fmt support
Browse files Browse the repository at this point in the history
  • Loading branch information
arBmind committed Oct 27, 2023
1 parent 615d7d5 commit 7c5f0e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/strong19.lib/strong19/Strong.fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ template<class T, class Char> requires(strong19::is_strong<T>) struct fmt::forma
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }

template<typename FormatContext> auto format(const T& v, FormatContext& ctx) {
return fmt::format_to(ctx.out(), "{} [{}]", v.v, strong19::strong_name<T>);
return fmt::format_to(ctx.out(), "{}{{{}}}", strong19::strong_name<T>, v.v);
}
};
7 changes: 4 additions & 3 deletions src/tuple19.lib/tuple19/Tuple.fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ template<class... Ts, class Char> struct fmt::formatter<tuple19::Tuple<Ts...>, C
return fmt::format_to(ctx.out(), "Tuple<>");
}
else {
[&]<size_t... Is>(std::index_sequence<0, Is...> const&) {
fmt::format_to(ctx.out(), "{}", v.template at<0>());
(fmt::format_to(ctx.out(), ", {}", v.template at<Is>()), ...);
return [&]<size_t... Is>(std::index_sequence<0, Is...> const&) {
auto out = fmt::format_to(ctx.out(), "{}", v.template at<0>());
((out = fmt::format_to(out, ", {}", v.template at<Is>())), ...);
return out;
}
(std::make_index_sequence<sizeof...(Ts)>{});
}
Expand Down

0 comments on commit 7c5f0e5

Please sign in to comment.