Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambiguous error in clang13 and c++20 #2013

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions include/spdlog/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ class SPDLOG_API logger
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<class T, typename std::enable_if<!std::is_convertible<const T &, spdlog::string_view_t>::value
&& !is_convertible_to_basic_format_string<const T&>::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);
Expand Down Expand Up @@ -132,14 +141,7 @@ class SPDLOG_API logger
{
log(source_loc{}, lvl, msg);
}

// T cannot be statically converted to string_view or wstring_view
template<class T, typename std::enable_if<!is_convertible_to_basic_format_string<T>::value, int>::type = 0>
void log(source_loc loc, level::level_enum lvl, const T &msg)
{
log(loc, lvl, "{}", msg);
}


template<typename... Args>
void trace(fmt::format_string<Args...> fmt, Args &&...args)
{
Expand Down