Skip to content

Commit fd4ffe7

Browse files
committed
updated fmt implementations to current recommendations
1 parent 038a68a commit fd4ffe7

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
/// noto: for this header you need fmt library (not included as library dependency)
66
#include <fmt/format.h>
77

8-
namespace fmt {
9-
10-
/// adds strong support for fmt
11-
template<enum19::HasMetaEnum T, class char_type> struct formatter<T, char_type> {
12-
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
8+
/// adds enum support for fmt
9+
template<enum19::HasMetaEnum T, class Char> struct fmt::formatter<T, Char> {
10+
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
1311

1412
template<typename FormatCtx> auto format(const T& v, FormatCtx& ctx) {
1513
auto underlying = static_cast<std::underlying_type_t<T>>(v);
16-
return format_to(ctx.out(), "{} ({})", valueName(v), underlying);
14+
return fmt::format_to(ctx.out(), "{} ({})", enum19::valueName(v), underlying);
1715
}
1816
};
19-
20-
} // namespace fmt

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
/// note: for this header you need fmt library (not included as library dependency)
55
#include <fmt/format.h>
66

7-
namespace fmt {
7+
template<class Char> struct fmt::formatter<string19::StringView, Char> {
8+
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
89

9-
/// adds strong support for fmt
10-
template<class char_type> struct formatter<string19::StringView, char_type> {
11-
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
12-
13-
template<typename FormatCtx> auto format(const string19::StringView& v, FormatCtx& ctx) {
10+
template<typename FormatContext> auto format(const string19::StringView& v, FormatContext& ctx) {
1411
auto out = ctx.out();
1512
for (auto i = 0u; i < v.count; i++) *out++ = v[i];
1613
return out;
1714
}
1815
};
19-
20-
} // namespace fmt

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
/// noto: for this header you need fmt library (not included as library dependency)
66
#include <fmt/format.h>
77

8-
namespace fmt {
9-
108
/// adds strong support for fmt
11-
template<class T, class char_type> requires(strong19::is_strong<T>) struct formatter<T, char_type> {
12-
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
9+
template<class T, class Char> requires(strong19::is_strong<T>) struct fmt::formatter<T, Char> {
10+
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx) { return ctx.begin(); }
1311

14-
template<typename FormatCtx> auto format(const T& v, FormatCtx& ctx) {
15-
return format_to(ctx.out(), "{} [{}]", v.v, strong19::strong_name<T>);
12+
template<typename FormatContext> auto format(const T& v, FormatContext& ctx) {
13+
return fmt::format_to(ctx.out(), "{} [{}]", v.v, strong19::strong_name<T>);
1614
}
1715
};
18-
19-
} // namespace fmt

0 commit comments

Comments
 (0)