From 715d7d2aa32047f7c843c3495578435d88c4776f Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Mon, 3 Jan 2022 14:16:31 -0700 Subject: [PATCH] Allow chrono to work with defined thousands separator This allows the 8.1.0 and later chrono.h implementation to work (i.e. do not emit any undefined symbol warnings) if the user has `FMT_STATIC_THOUSANDS_SEPARATOR` defined. The chrono implementation is relying on this definition of `locale_ref` to be defined. Moving the `#ifndef` line to still define `locale_ref` and only select which version of `thousands_sep_impl` gets defined. --- include/fmt/format-inl.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 04ded482..f2334e05 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -17,10 +17,7 @@ #include // std::memmove #include #include - -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR -# include -#endif +#include #ifdef _WIN32 # include // _isatty @@ -96,7 +93,6 @@ inline void fwrite_fully(const void* ptr, size_t size, size_t count, if (written < count) FMT_THROW(system_error(errno, "cannot write to file")); } -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR template locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { static_assert(std::is_same::value, ""); @@ -107,6 +103,7 @@ template Locale locale_ref::get() const { return locale_ ? *static_cast(locale_) : std::locale(); } +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR template FMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result { auto& facet = std::use_facet>(loc.get());