mirror of
https://github.com/gabime/spdlog.git
synced 2025-03-15 10:39:53 +08:00
enable_if
This commit is contained in:
parent
d6dbdbf27a
commit
e69699e12c
@ -74,8 +74,7 @@ public:
|
|||||||
void swap(spdlog::logger &other) SPDLOG_NOEXCEPT;
|
void swap(spdlog::logger &other) SPDLOG_NOEXCEPT;
|
||||||
|
|
||||||
// FormatString is a type derived from fmt::compile_string
|
// FormatString is a type derived from fmt::compile_string
|
||||||
template<typename FormatString, typename std::enable_if<fmt::is_compile_string<FormatString>::value, int>::type * = nullptr,
|
template<typename FormatString, typename std::enable_if<fmt::is_compile_string<FormatString>::value, int>::type = 0, typename... Args>
|
||||||
typename... Args>
|
|
||||||
void log(source_loc loc, level::level_enum lvl, const FormatString &fmt, const Args &... args)
|
void log(source_loc loc, level::level_enum lvl, const FormatString &fmt, const Args &... args)
|
||||||
{
|
{
|
||||||
log_(loc, lvl, fmt, args...);
|
log_(loc, lvl, fmt, args...);
|
||||||
@ -137,9 +136,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// T can be statically converted to string_view and isn't a fmt::compile_string
|
// T can be statically converted to string_view and isn't a fmt::compile_string
|
||||||
template<class T,
|
template<class T, typename std::enable_if<
|
||||||
typename std::enable_if<std::is_convertible<const T &, spdlog::string_view_t>::value && !fmt::is_compile_string<T>::value, T>::type
|
std::is_convertible<const T &, spdlog::string_view_t>::value && !fmt::is_compile_string<T>::value, int>::type = 0>
|
||||||
* = 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)
|
||||||
{
|
{
|
||||||
log(loc, lvl, string_view_t{msg});
|
log(loc, lvl, string_view_t{msg});
|
||||||
@ -179,7 +177,7 @@ public:
|
|||||||
// T cannot be statically converted to string_view or wstring_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 &&
|
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,
|
!is_convertible_to_wstring_view<const T &>::value,
|
||||||
T>::type * = nullptr>
|
int>::type = 0>
|
||||||
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
log(loc, lvl, "{}", msg);
|
log(loc, lvl, "{}", msg);
|
||||||
@ -250,7 +248,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<is_convertible_to_wstring_view<const T &>::value, T>::type * = nullptr>
|
template<class T, typename std::enable_if<is_convertible_to_wstring_view<const T &>::value, int>::type = 0>
|
||||||
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
void log(source_loc loc, level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
bool log_enabled = should_log(lvl);
|
bool log_enabled = should_log(lvl);
|
||||||
|
Loading…
Reference in New Issue
Block a user