mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Fix ambiguous overload errors
This commit is contained in:
parent
4ef4d0659d
commit
eb51f37c67
@ -95,7 +95,13 @@ using string_view_t = basic_string_view_t<char>;
|
|||||||
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
|
#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows
|
||||||
#else
|
#else
|
||||||
using wstring_view_t = basic_string_view_t<wchar_t>;
|
using wstring_view_t = basic_string_view_t<wchar_t>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_convertible_to_wstring_view : std::is_convertible<T, wstring_view_t> { };
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
#else
|
||||||
|
template<typename>
|
||||||
|
struct is_convertible_to_wstring_view : std::false_type { };
|
||||||
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
|
|
||||||
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
||||||
|
@ -155,8 +155,8 @@ public:
|
|||||||
sink_it_(log_msg);
|
sink_it_(log_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// T cannot be statically converted to string_view
|
// T cannot be statically converted to string_view or wstring_view
|
||||||
template<class T, typename std::enable_if<!std::is_convertible<const T &, spdlog::string_view_t>::value, T>::type * = nullptr>
|
template<class T, typename std::enable_if<!std::is_convertible<const T &, spdlog::string_view_t>::value && !is_convertible_to_wstring_view<const T &>::value, T>::type * = nullptr>
|
||||||
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
if (!should_log(lvl))
|
if (!should_log(lvl))
|
||||||
@ -279,7 +279,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// T can be statically converted to wstring_view
|
// T can be statically converted to wstring_view
|
||||||
template<class T, typename std::enable_if<std::is_convertible<const T &, spdlog::wstring_view_t>::value, T>::type * = nullptr>
|
template<class T, typename std::enable_if<is_convertible_to_wstring_view<const T &>::value, T>::type * = nullptr>
|
||||||
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
if (!should_log(lvl))
|
if (!should_log(lvl))
|
||||||
@ -292,7 +292,7 @@ public:
|
|||||||
fmt::memory_buffer buf;
|
fmt::memory_buffer buf;
|
||||||
details::os::wstr_to_utf8buf(msg, buf);
|
details::os::wstr_to_utf8buf(msg, buf);
|
||||||
|
|
||||||
details::log_msg log_msg(loc, name_, lvl, buf);
|
details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
|
||||||
sink_it_(log_msg);
|
sink_it_(log_msg);
|
||||||
}
|
}
|
||||||
SPDLOG_LOGGER_CATCH()
|
SPDLOG_LOGGER_CATCH()
|
||||||
|
Loading…
Reference in New Issue
Block a user