Fix compilation with locales disabled (#1011)

This commit is contained in:
Victor Zverovich 2019-01-19 07:16:05 -08:00
parent dad1eec842
commit fdd8e333c1
3 changed files with 9 additions and 0 deletions

View File

@ -9,8 +9,11 @@
FMT_BEGIN_NAMESPACE
template struct internal::basic_data<void>;
#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<std::locale>() const;
#endif
// Explicit instantiations for char.

View File

@ -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

View File

@ -8,6 +8,7 @@
#include "fmt/locale.h"
#include "gmock.h"
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template <typename Char> struct numpunct : std::numpunct<Char> {
protected:
Char do_thousands_sep() const FMT_OVERRIDE { return '~'; }
@ -31,3 +32,4 @@ TEST(LocaleTest, WFormat) {
fmt::format_arg_store<fmt::wformat_context, int> as{1234567};
EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:n}", fmt::wformat_args(as)));
}
#endif // FMT_STATIC_THOUSANDS_SEPARATOR