1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-05-03 05:23:51 +00:00

Fixed build

This commit is contained in:
gabime 2023-09-16 17:23:04 +03:00
parent 536da46a2c
commit 3979bd15f7
2 changed files with 12 additions and 4 deletions

View File

@ -339,18 +339,26 @@ constexpr spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) noex
} }
#endif #endif
// convert format_string<...> to string_view depending on std::format or {fmt} versions
#ifndef SPDLOG_USE_STD_FORMAT #ifndef SPDLOG_USE_STD_FORMAT
template<typename T, typename... Args> template<typename T, typename... Args>
inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) constexpr inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) noexcept
{ {
return fmt; return fmt;
} }
#elif __cpp_lib_format >= 202207L #elif __cpp_lib_format >= 202207L // std::format and __cpp_lib_format >= 202207L
template<typename T, typename... Args> template<typename T, typename... Args>
constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept
{ {
return fmt.get(); return fmt.get();
} }
#else // std::format and __cpp_lib_format < 202207L
template<typename T, typename... Args>
constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept
{
return fmt;
}
#endif #endif
} // namespace details } // namespace details

View File

@ -81,7 +81,7 @@ public:
{ {
if (should_log(lvl)) if (should_log(lvl))
{ {
log_with_format_(loc, lvl, fmt.get(), std::forward<Args>(args)...); log_with_format_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
} }
} }
@ -90,7 +90,7 @@ public:
{ {
if (should_log(lvl)) if (should_log(lvl))
{ {
log_with_format_(source_loc{}, lvl, fmt.get(), std::forward<Args>(args)...); log_with_format_(source_loc{}, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
} }
} }