From e5d599875c025f08f6f8bea6e50b35386a3500cb Mon Sep 17 00:00:00 2001 From: vitaut Date: Fri, 20 Nov 2015 07:56:16 -0800 Subject: [PATCH] Improve compatibility with bcc32 --- format.cc | 6 ++++-- format.h | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/format.cc b/format.cc index 9c7fcf2f..270d4591 100644 --- a/format.cc +++ b/format.cc @@ -1285,13 +1285,15 @@ void fmt::BasicFormatter::format(BasicCStringRef format_str) { FMT_FUNC void fmt::report_system_error( int error_code, fmt::StringRef message) FMT_NOEXCEPT { - report_error(internal::format_system_error, error_code, message); + // 'fmt::' is for bcc32. + fmt::report_error(internal::format_system_error, error_code, message); } #if FMT_USE_WINDOWS_H FMT_FUNC void fmt::report_windows_error( int error_code, fmt::StringRef message) FMT_NOEXCEPT { - report_error(internal::format_windows_error, error_code, message); + // 'fmt::' is for bcc32. + fmt::report_error(internal::format_windows_error, error_code, message); } #endif diff --git a/format.h b/format.h index 2dd3fe49..055b7624 100644 --- a/format.h +++ b/format.h @@ -927,19 +927,20 @@ struct WCharHelper { typedef Null Unsupported; }; +typedef char Yes[1]; +typedef char No[2]; + +// These are non-members to workaround an overload resolution bug in bcc32. +Yes &convert(fmt::ULongLong); +No &convert(...); + template class IsConvertibleToInt { protected: - typedef char yes[1]; - typedef char no[2]; - static const T &get(); - static yes &convert(fmt::ULongLong); - static no &convert(...); - public: - enum { value = (sizeof(convert(get())) == sizeof(yes)) }; + enum { value = (sizeof(convert(get())) == sizeof(Yes)) }; }; #define FMT_CONVERTIBLE_TO_INT(Type) \ @@ -1099,7 +1100,7 @@ class MakeValue : public Arg { template MakeValue(const T &value, - typename EnableIf::value, int>::type = 0) { + typename EnableIf::value == 0, int>::type = 0) { custom.value = &value; custom.format = &format_custom_arg; } @@ -1765,8 +1766,8 @@ inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) { # define FMT_MAKE_TEMPLATE_ARG(n) typename T##n # define FMT_MAKE_ARG_TYPE(n) T##n # define FMT_MAKE_ARG(n) const T##n &v##n -# define FMT_MAKE_REF_char(n) fmt::internal::MakeValue(v##n) -# define FMT_MAKE_REF_wchar_t(n) fmt::internal::MakeValue(v##n) +# define FMT_ASSIGN_char(n) arr[n] = fmt::internal::MakeValue(v##n) +# define FMT_ASSIGN_wchar_t(n) arr[n] = fmt::internal::MakeValue(v##n) #if FMT_USE_VARIADIC_TEMPLATES // Defines a variadic function returning void. @@ -2985,7 +2986,8 @@ void arg(WStringRef, const internal::NamedArg&) FMT_DELETED_OR_UNDEFINED; template \ inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__), \ FMT_GEN(n, FMT_MAKE_ARG)) { \ - fmt::internal::ArgArray::Type arr = {FMT_GEN(n, FMT_MAKE_REF_##Char)}; \ + fmt::internal::ArgArray::Type arr; \ + FMT_GEN(n, FMT_ASSIGN_##Char); \ call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \ fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \ }