diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 4f0c9bd9..95c3e50b 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -22,13 +22,6 @@ #include "format.h" -#ifdef FMT_USE_LOCALE -// Use the provided definition. -#elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) -# define FMT_USE_LOCALE 0 -#else -# define FMT_USE_LOCALE 1 -#endif #if FMT_USE_LOCALE # include #elif !defined(FMT_STATIC_THOUSANDS_SEPARATOR) @@ -122,9 +115,9 @@ FMT_FUNC auto decimal_point_impl(locale_ref loc) -> Char { return use_facet>(loc.get()).decimal_point(); } +#if FMT_USE_LOCALE FMT_FUNC auto write_loc(appender out, loc_value value, const format_specs& specs, locale_ref loc) -> bool { -#if FMT_USE_LOCALE auto locale = loc.get(); // We cannot use the num_put facet because it may produce output in // a wrong encoding. @@ -132,12 +125,8 @@ FMT_FUNC auto write_loc(appender out, loc_value value, if (std::has_facet(locale)) return use_facet(locale).put(out, value, specs); return facet(locale).put(out, value, specs); -#else - value.visit(loc_writer<>{ - out, specs, std::string(1, FMT_STATIC_THOUSANDS_SEPARATOR), "\3", "."}); - return true; -#endif } +#endif } // namespace detail FMT_FUNC void report_error(const char* message) { diff --git a/include/fmt/format.h b/include/fmt/format.h index f70a33dc..85b2abd1 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -799,6 +799,14 @@ using is_double_double = bool_constant::digits == 106>; # define FMT_USE_FULL_CACHE_DRAGONBOX 0 #endif +#ifdef FMT_USE_LOCALE +// Use the provided definition. +#elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) +# define FMT_USE_LOCALE 0 +#else +# define FMT_USE_LOCALE 1 +#endif + template struct is_locale : std::false_type {}; template @@ -2144,9 +2152,11 @@ auto write_int(OutputIt out, UInt value, unsigned prefix, }); } +#if FMT_USE_LOCALE // Writes a localized value. FMT_API auto write_loc(appender out, loc_value value, const format_specs& specs, locale_ref loc) -> bool; +#endif template inline auto write_loc(OutputIt, loc_value, const format_specs&, locale_ref) -> bool {