From b42605630ed8ec71245943ef9b8af92e3849421d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 22 Sep 2024 15:31:52 -0700 Subject: [PATCH] Cleanup format API --- include/fmt/format.h | 46 +++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index b2dee309f437d..87f0e4c4d42a7 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1297,6 +1297,17 @@ template <> inline auto decimal_point(locale_ref loc) -> wchar_t { return decimal_point_impl(loc); } +#ifndef FMT_HEADER_ONLY +FMT_BEGIN_EXPORT +extern template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +extern template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +extern template FMT_API auto decimal_point_impl(locale_ref) -> char; +extern template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; +FMT_END_EXPORT +#endif // FMT_HEADER_ONLY + // Compares two characters for equality. template auto equal2(const Char* lhs, const char* rhs) -> bool { return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]); @@ -3804,19 +3815,6 @@ using fmt::report_error; FMT_API void report_error(format_func func, int error_code, const char* message) noexcept; -FMT_BEGIN_EXPORT - -#ifndef FMT_HEADER_ONLY -extern template FMT_API auto thousands_sep_impl(locale_ref) - -> thousands_sep_result; -extern template FMT_API auto thousands_sep_impl(locale_ref) - -> thousands_sep_result; -extern template FMT_API auto decimal_point_impl(locale_ref) -> char; -extern template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; -#endif // FMT_HEADER_ONLY - -FMT_END_EXPORT - template template FMT_CONSTEXPR auto native_formatter::format( @@ -3834,17 +3832,6 @@ FMT_CONSTEXPR auto native_formatter::format( FMT_BEGIN_EXPORT -template -struct formatter>> - : formatter, Char> { - template - FMT_CONSTEXPR auto format(const T& value, FormatContext& ctx) const - -> decltype(ctx.out()) { - auto&& val = format_as(value); // Make an lvalue reference for format. - return formatter, Char>::format(val, ctx); - } -}; - #define FMT_FORMAT_AS(Type, Base) \ template \ struct formatter : formatter { \ @@ -3884,6 +3871,17 @@ struct formatter : detail::native_formatter {}; +template +struct formatter>> + : formatter, Char> { + template + FMT_CONSTEXPR auto format(const T& value, FormatContext& ctx) const + -> decltype(ctx.out()) { + auto&& val = format_as(value); // Make an lvalue reference for format. + return formatter, Char>::format(val, ctx); + } +}; + /** * Converts `p` to `const void*` for pointer formatting. *