From 9049f9aeb9db1e8a3cbce49c696dae1b9bb4e182 Mon Sep 17 00:00:00 2001 From: gabime Date: Tue, 27 Jul 2021 00:26:32 +0300 Subject: [PATCH] Fix ambiguous error in clang13 and c++20 --- include/spdlog/logger.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 6cbcdf6f..fe9db35f 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -102,6 +102,15 @@ public: log(loc, lvl, string_view_t{msg}); } + // T cannot be statically converted to niether string_view, neither wstring_view and niether to format string + template::value + && !is_convertible_to_basic_format_string::value, + int>::type = 0> + void log(source_loc loc, level::level_enum lvl, const T &msg) + { + log(loc, lvl, "{}", msg); + } + void log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, string_view_t msg) { bool log_enabled = should_log(lvl); @@ -132,14 +141,7 @@ public: { log(source_loc{}, lvl, msg); } - - // T cannot be statically converted to string_view or wstring_view - template::value, int>::type = 0> - void log(source_loc loc, level::level_enum lvl, const T &msg) - { - log(loc, lvl, "{}", msg); - } - + template void trace(fmt::format_string fmt, Args &&...args) {