diff --git a/include/fmt/core.h b/include/fmt/core.h index a867d8d7..33830eef 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1301,28 +1301,22 @@ struct wformat_args : basic_format_args { : basic_format_args(std::forward(arg)...) {} }; +#define FMT_ENABLE_IF_T(B, T) typename std::enable_if::type + #ifndef FMT_USE_ALIAS_TEMPLATES # define FMT_USE_ALIAS_TEMPLATES FMT_HAS_FEATURE(cxx_alias_templates) #endif #if FMT_USE_ALIAS_TEMPLATES /** String's character type. */ template -using char_t = typename std::enable_if::value, - typename internal::char_t::type>::type; +using char_t = FMT_ENABLE_IF_T( + internal::is_string::value, typename internal::char_t::type); #define FMT_CHAR(S) fmt::char_t - -template -using enable_if_string_t = - typename std::enable_if::value, T>::type; -#define FMT_ENABLE_IF_STRING(S, T) enable_if_string_t #else template struct char_t : std::enable_if< internal::is_string::value, typename internal::char_t::type> {}; #define FMT_CHAR(S) typename char_t::type - -#define FMT_ENABLE_IF_STRING(S, T) \ - typename std::enable_if::value, T>::type #endif namespace internal { @@ -1478,7 +1472,7 @@ FMT_API void vprint(std::FILE *f, wstring_view format_str, wformat_args args); \endrst */ template -inline FMT_ENABLE_IF_STRING(S, void) +inline FMT_ENABLE_IF_T(internal::is_string::value, void) print(std::FILE *f, const S &format_str, const Args &... args) { vprint(f, to_string_view(format_str), internal::checked_args(format_str, args...)); @@ -1497,7 +1491,7 @@ FMT_API void vprint(wstring_view format_str, wformat_args args); \endrst */ template -inline FMT_ENABLE_IF_STRING(S, void) +inline FMT_ENABLE_IF_T(internal::is_string::value, void) print(const S &format_str, const Args &... args) { vprint(to_string_view(format_str), internal::checked_args(format_str, args...)); diff --git a/include/fmt/format.h b/include/fmt/format.h index 33df6653..2f8d2b86 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -165,8 +165,6 @@ FMT_END_NAMESPACE # define FMT_USE_TRAILING_RETURN 0 #endif -#define FMT_ENABLE_IF_T(B, T) typename std::enable_if::type - #ifndef FMT_USE_GRISU # define FMT_USE_GRISU 0 //# define FMT_USE_GRISU std::numeric_limits::is_iec559 diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 7804b953..2e8d800f 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -626,7 +626,8 @@ vsprintf(const S &format, \endrst */ template -inline FMT_ENABLE_IF_STRING(S, std::basic_string) +inline FMT_ENABLE_IF_T( + internal::is_string::value, std::basic_string) sprintf(const S &format, const Args & ... args) { internal::check_format_string(format); typedef internal::basic_buffer buffer; @@ -657,7 +658,7 @@ inline int vfprintf(std::FILE *f, const S &format, \endrst */ template -inline FMT_ENABLE_IF_STRING(S, int) +inline FMT_ENABLE_IF_T(internal::is_string::value, int) fprintf(std::FILE *f, const S &format, const Args & ... args) { internal::check_format_string(format); typedef internal::basic_buffer buffer; @@ -684,7 +685,7 @@ inline int vprintf(const S &format, \endrst */ template -inline FMT_ENABLE_IF_STRING(S, int) +inline FMT_ENABLE_IF_T(internal::is_string::value, int) printf(const S &format_str, const Args & ... args) { internal::check_format_string(format_str); typedef internal::basic_buffer buffer; @@ -715,7 +716,7 @@ inline int vfprintf(std::basic_ostream &os, \endrst */ template -inline FMT_ENABLE_IF_STRING(S, int) +inline FMT_ENABLE_IF_T(internal::is_string::value, int) fprintf(std::basic_ostream &os, const S &format_str, const Args & ... args) { internal::check_format_string(format_str);