Skip to content

Commit 6b461f0

Browse files
committed
mark format methods const
1 parent 7fd7769 commit 6b461f0

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/enum19.lib/enum19/Enum.fmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
template<enum19::HasMetaEnum T, class Char> struct fmt::formatter<T, Char> {
1010
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
1111

12-
template<typename FormatCtx> auto format(const T& v, FormatCtx& ctx) {
12+
template<typename FormatCtx> auto format(const T& v, FormatCtx& ctx) const {
1313
auto underlying = static_cast<std::underlying_type_t<T>>(v);
1414
return fmt::format_to(ctx.out(), "{} ({})", enum19::valueName(v), underlying);
1515
}

src/string19.lib/string19/StringView.fmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
template<class Char> struct fmt::formatter<string19::StringView, Char> {
88
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
99

10-
template<typename FormatContext> auto format(const string19::StringView& v, FormatContext& ctx) {
10+
template<typename FormatContext> auto format(const string19::StringView& v, FormatContext& ctx) const {
1111
auto out = ctx.out();
1212
for (auto i = 0u; i < v.count; i++) *out++ = v[i];
1313
return out;

src/strong19.lib/strong19/Strong.fmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
template<class T, class Char> requires(strong19::is_strong<T>) struct fmt::formatter<T, Char> {
1010
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
1111

12-
template<typename FormatContext> auto format(const T& v, FormatContext& ctx) {
12+
template<typename FormatContext> auto format(const T& v, FormatContext& ctx) const {
1313
return fmt::format_to(ctx.out(), "{}{{{}}}", strong19::strong_name<T>, v.v);
1414
}
1515
};

src/tuple19.lib/tuple19/Tuple.fmt.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ namespace tuple19 {
1212
template<class... Ts> constexpr auto make_format_args(Tuple<Ts...> const& args) {
1313
return [&]<size_t... Is>(std::index_sequence<Is...> const&) {
1414
return fmt::make_format_args(args.template at<Is>()...);
15-
}
16-
(std::make_index_sequence<sizeof...(Ts)>{});
15+
}(std::make_index_sequence<sizeof...(Ts)>{});
1716
}
1817

1918
} // namespace tuple19
2019

2120
template<class... Ts, class Char> struct fmt::formatter<tuple19::Tuple<Ts...>, Char> {
2221
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
2322

24-
template<typename FormatContext> auto format(tuple19::Tuple<Ts...> const& v, FormatContext& ctx) {
23+
template<typename FormatContext> auto format(tuple19::Tuple<Ts...> const& v, FormatContext& ctx) const {
2524
if constexpr (sizeof...(Ts) == 0) {
2625
return fmt::format_to(ctx.out(), "Tuple<>");
2726
}
@@ -30,8 +29,7 @@ template<class... Ts, class Char> struct fmt::formatter<tuple19::Tuple<Ts...>, C
3029
auto out = fmt::format_to(ctx.out(), "{}", v.template at<0>());
3130
((out = fmt::format_to(out, ", {}", v.template at<Is>())), ...);
3231
return out;
33-
}
34-
(std::make_index_sequence<sizeof...(Ts)>{});
32+
}(std::make_index_sequence<sizeof...(Ts)>{});
3533
}
3634
}
3735
};

0 commit comments

Comments
 (0)