diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 518da900..9a425464 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -116,6 +116,17 @@ 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 @@ -123,9 +134,9 @@ using wmemory_buf_t = fmt::basic_memory_buffer; template struct is_convertible_to_wstring_view : std::is_convertible {}; + template -struct is_convertible_to_wformat_string : std::is_convertible> -{}; +using is_convertible_to_wformat_string = is_convertible_to_basic_format_string; # endif // _WIN32 #else template @@ -137,8 +148,12 @@ struct is_convertible_to_wformat_string : std::false_type #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_string_view + : std::integral_constant::value || is_convertible_to_wstring_view::value> +{}; +template +struct is_convertible_to_any_format_string + : std::integral_constant::value || is_convertible_to_wformat_string::value> {}; #if defined(SPDLOG_NO_ATOMIC_LEVELS) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 2e58628f..1d23c5a6 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -103,9 +103,9 @@ public: } // 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> + template::value && !is_convertible_to_any_format_string::value, int>::type = 0> void log(source_loc loc, level::level_enum lvl, const T &msg) { log(loc, lvl, "{}", msg);