diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 9223281e..4130107e 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -254,21 +254,12 @@ template <> FMT_FUNC int count_digits<4>(internal::uintptr_t n) { } template -int char_traits::format_float(char* buf, std::size_t size, - const char* format, int precision, - T value) { +int format_float(char* buf, std::size_t size, const char* format, int precision, + T value) { return precision < 0 ? FMT_SNPRINTF(buf, size, format, value) : FMT_SNPRINTF(buf, size, format, precision, value); } -template -int char_traits::format_float(wchar_t* buf, std::size_t size, - const wchar_t* format, int precision, - T value) { - return precision < 0 ? FMT_SWPRINTF(buf, size, format, value) - : FMT_SWPRINTF(buf, size, format, precision, value); -} - template const char basic_data::DIGITS[] = "0001020304050607080910111213141516171819" @@ -758,8 +749,8 @@ void sprintf_format(Double value, internal::buffer& buf, for (;;) { std::size_t buffer_size = buf.capacity(); start = &buf[0]; - int result = internal::char_traits::format_float( - start, buffer_size, format, spec.precision, value); + int result = + format_float(start, buffer_size, format, spec.precision, value); if (result >= 0) { unsigned n = internal::to_unsigned(result); if (n < buf.capacity()) { diff --git a/include/fmt/format.h b/include/fmt/format.h index 0ceb8233..782cf9b6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -552,40 +552,6 @@ typedef basic_memory_buffer wmemory_buffer; namespace internal { -template struct char_traits; - -template <> struct char_traits { - // Formats a floating-point number. - template - FMT_API static int format_float(char* buffer, std::size_t size, - const char* format, int precision, T value); -}; - -template <> struct char_traits { - template - FMT_API static int format_float(wchar_t* buffer, std::size_t size, - const wchar_t* format, int precision, - T value); -}; - -#if FMT_USE_EXTERN_TEMPLATES -extern template int char_traits::format_float(char* buffer, - std::size_t size, - const char* format, - int precision, - double value); -extern template int char_traits::format_float( - char* buffer, std::size_t size, const char* format, int precision, - long double value); - -extern template int char_traits::format_float( - wchar_t* buffer, std::size_t size, const wchar_t* format, int precision, - double value); -extern template int char_traits::format_float( - wchar_t* buffer, std::size_t size, const wchar_t* format, int precision, - long double value); -#endif - // A workaround for std::string not having mutable data() until C++17. template inline Char* get_data(std::basic_string& s) { return &s[0]; diff --git a/src/format.cc b/src/format.cc index bb1aa627..7236def4 100644 --- a/src/format.cc +++ b/src/format.cc @@ -28,16 +28,6 @@ template FMT_API void internal::buffer::append(const char*, const char*); template FMT_API void internal::arg_map::init( const basic_format_args& args); -template FMT_API int internal::char_traits::format_float(char*, - std::size_t, - const char*, int, - double); - -template FMT_API int internal::char_traits::format_float(char*, - std::size_t, - const char*, int, - long double); - template FMT_API std::string internal::vformat( string_view, basic_format_args); @@ -60,12 +50,6 @@ template FMT_API void internal::buffer::append(const wchar_t*, template FMT_API void internal::arg_map::init( const basic_format_args&); -template FMT_API int internal::char_traits::format_float( - wchar_t*, std::size_t, const wchar_t*, int, double); - -template FMT_API int internal::char_traits::format_float( - wchar_t*, std::size_t, const wchar_t*, int, long double); - template FMT_API std::wstring internal::vformat( wstring_view, basic_format_args); FMT_END_NAMESPACE diff --git a/test/format-test.cc b/test/format-test.cc index 34550bc2..188e2dac 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2538,3 +2538,8 @@ TEST(FormatTest, EmphasisNonHeaderOnly) { EXPECT_EQ(fmt::format(fmt::emphasis::bold, "bold error"), "\x1b[1mbold error\x1b[0m"); } + +TEST(FormatTest, CharTraitsIsNotAmbiguous) { + using namespace std; + char_traits::char_type c; +}