diff --git a/include/fmt/core.h b/include/fmt/core.h index 5912afef..3ec08c7b 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -233,6 +233,9 @@ FMT_CONSTEXPR size_t length(const Char *s) { #if FMT_GCC_VERSION FMT_CONSTEXPR size_t length(const char *s) { return std::strlen(s); } #endif + +template +struct no_formatter_error : std::false_type {}; } // namespace internal /** @@ -340,13 +343,10 @@ class basic_format_arg; template class basic_format_args; -template -struct no_formatter_error : std::false_type {}; - // A formatter for objects of type T. template struct formatter { - static_assert(no_formatter_error::value, + static_assert(internal::no_formatter_error::value, "don't know how to format the type, include fmt/ostream.h if it provides " "an operator<< that should be used"); @@ -472,17 +472,6 @@ struct error_handler { FMT_API void on_error(const char *message); }; -// Formatting of wide characters and strings into a narrow output is disallowed: -// fmt::format("{}", L"test"); // error -// To fix this, use a wide format string: -// fmt::format(L"{}", L"test"); -template -inline void require_wchar() { - static_assert( - std::is_same::value, - "formatting of wide characters into a narrow output is disallowed"); -} - template struct named_arg_base; @@ -639,15 +628,12 @@ FMT_MAKE_VALUE_SAME(long_long_type, long long) FMT_MAKE_VALUE_SAME(ulong_long_type, unsigned long long) FMT_MAKE_VALUE(int_type, signed char, int) FMT_MAKE_VALUE(uint_type, unsigned char, unsigned) -FMT_MAKE_VALUE(char_type, char, int) +FMT_MAKE_VALUE(char_type, typename C::char_type, int) -#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) template -inline init make_value(wchar_t val) { - require_wchar(); - return static_cast(val); -} -#endif +FMT_CONSTEXPR typename std::enable_if< + !std::is_same::value, + init>::type make_value(char val) { return val; } FMT_MAKE_VALUE(double_type, float, double) FMT_MAKE_VALUE_SAME(double_type, double) diff --git a/include/fmt/format.h b/include/fmt/format.h index 9f522f39..d88b78c1 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2740,9 +2740,8 @@ class basic_writer { void write(char value) { *reserve(1) = value; } - void write(wchar_t value) { - internal::require_wchar(); + static_assert(std::is_same::value, ""); *reserve(1) = value; } @@ -2755,9 +2754,8 @@ class basic_writer { auto &&it = reserve(value.size()); it = std::copy(value.begin(), value.end(), it); } - void write(wstring_view value) { - internal::require_wchar(); + static_assert(std::is_same::value, ""); auto &&it = reserve(value.size()); it = std::copy(value.begin(), value.end(), it); }