From fdd8e333c18058648b3e7aea6605680a0b42c7b5 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 19 Jan 2019 07:16:05 -0800 Subject: [PATCH] Fix compilation with locales disabled (#1011) --- src/format.cc | 3 +++ test/chrono-test.cc | 4 ++++ test/locale-test.cc | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/format.cc b/src/format.cc index 4b2163d4..33a97ffc 100644 --- a/src/format.cc +++ b/src/format.cc @@ -9,8 +9,11 @@ FMT_BEGIN_NAMESPACE template struct internal::basic_data; + +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR template FMT_API internal::locale_ref::locale_ref(const std::locale& loc); template FMT_API std::locale internal::locale_ref::get() const; +#endif // Explicit instantiations for char. diff --git a/test/chrono-test.cc b/test/chrono-test.cc index 77df8af6..d6e9c1d3 100644 --- a/test/chrono-test.cc +++ b/test/chrono-test.cc @@ -50,6 +50,8 @@ std::string format_tm(const std::tm& time, const char* spec, fmt::format(loc, "{:" spec "}", duration)); \ } +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR + TEST(ChronoTest, FormatDefault) { EXPECT_EQ("42s", fmt::format("{}", std::chrono::seconds(42))); EXPECT_EQ("42as", @@ -186,3 +188,5 @@ TEST(ChronoTest, Locale) { EXPECT_TIME("%r", time, sec); EXPECT_TIME("%p", time, sec); } + +#endif // FMT_STATIC_THOUSANDS_SEPARATOR diff --git a/test/locale-test.cc b/test/locale-test.cc index 980780c8..25a68eaf 100644 --- a/test/locale-test.cc +++ b/test/locale-test.cc @@ -8,6 +8,7 @@ #include "fmt/locale.h" #include "gmock.h" +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR template struct numpunct : std::numpunct { protected: Char do_thousands_sep() const FMT_OVERRIDE { return '~'; } @@ -31,3 +32,4 @@ TEST(LocaleTest, WFormat) { fmt::format_arg_store as{1234567}; EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:n}", fmt::wformat_args(as))); } +#endif // FMT_STATIC_THOUSANDS_SEPARATOR