diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 518da900..ed0ab46c 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -116,29 +116,26 @@ using wstring_view_t = fmt::basic_string_view; using memory_buf_t = fmt::basic_memory_buffer; using wmemory_buf_t = fmt::basic_memory_buffer; +template +using remove_cvref_t = typename std::remove_cv::type>::type; + +// clang doesn't like SFINAE disabled constructor in std::is_convertible<> so have to repeat the condition from basic_format_string here, +// in addition, fmt::basic_runtime is only convertible to basic_format_string but not basic_string_view +template +struct is_convertible_to_basic_format_string + : std::integral_constant>::value || std::is_same, fmt::basic_runtime>::value> +{}; + #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT # ifndef _WIN32 # error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows -# else -template -struct is_convertible_to_wstring_view : std::is_convertible -{}; -template -struct is_convertible_to_wformat_string : std::is_convertible> -{}; # endif // _WIN32 -#else -template -struct is_convertible_to_wstring_view : std::false_type -{}; -template -struct is_convertible_to_wformat_string : std::false_type -{}; -#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT +#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT template -struct is_convertible_to_basic_format_string - : std::integral_constant>::value || is_convertible_to_wformat_string::value> +struct is_convertible_to_any_format_string : std::integral_constant::value || + is_convertible_to_basic_format_string::value> {}; #if defined(SPDLOG_NO_ATOMIC_LEVELS) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 2e58628f..ff3bef58 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -102,10 +102,8 @@ public: log(loc, lvl, string_view_t{msg}); } - // T cannot be statically converted to neither string_view, nor wstring_view and nor format string - template::value && - !is_convertible_to_basic_format_string::value, - int>::type = 0> + // T cannot be statically converted to format string (including string_view) + template::value, int>::type = 0> void log(source_loc loc, level::level_enum lvl, const T &msg) { log(loc, lvl, "{}", msg);