From 17b9e4db8c7edd270adf459270be5bcfc13f4292 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 26 Feb 2015 06:21:54 -0800 Subject: [PATCH] Improve error reporting when trying to write wchar_t with a char writer --- format.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/format.h b/format.h index 7a9cc540..e0c07f17 100644 --- a/format.h +++ b/format.h @@ -1610,11 +1610,13 @@ class BasicWriter { void write_str( const internal::Arg::StringValue &str, const FormatSpec &spec); - // This method is private to disallow writing a wide string to a - // char stream and vice versa. If you want to print a wide string - // as a pointer as std::ostream does, cast it to const void*. + // This following methods are private to disallow writing wide characters + // and strings to a char stream. If you want to print a wide string as a + // pointer as std::ostream does, cast it to const void*. // Do not implement! void operator<<(typename internal::CharTraits::UnsupportedStrType); + void operator<<(typename internal::WCharHelper::Unsupported); + // Appends floating-point length specifier to the format string. // The second argument is only used for overload resolution. @@ -1744,8 +1746,9 @@ class BasicWriter { return *this; } - BasicWriter &operator<<(wchar_t value) { - buffer_.push_back(internal::CharTraits::convert(value)); + BasicWriter &operator<<( + typename internal::WCharHelper::Supported value) { + buffer_.push_back(value); return *this; }