alwaus use std::string_view

This commit is contained in:
gabime 2024-11-29 13:52:17 +02:00
parent 62534f2e4e
commit fb3969d540
2 changed files with 7 additions and 7 deletions

View File

@ -95,28 +95,28 @@ using sink_ptr = std::shared_ptr<sinks::sink>;
using sinks_init_list = std::initializer_list<sink_ptr>;
using err_handler = std::function<void(const std::string &err_msg)>;
using string_view_t = std::basic_string_view<char>;
using wstring_view_t = std::basic_string_view<wchar_t>;
#ifdef SPDLOG_USE_STD_FORMAT
namespace fmt_lib = std;
using string_view_t = std::string_view;
using memory_buf_t = std::string;
using wstring_view_t = std::wstring_view;
using wmemory_buf_t = std::wstring;
template <typename... Args>
#if __cpp_lib_format >= 202207L
using format_string_t = std::format_string<Args...>;
using format_string_t = std::format_string<Args...>;
#else
using format_string_t = std::string_view;
using format_string_t = std::string_view;
#endif
#define SPDLOG_BUF_TO_STRING(x) x
#else // use fmt lib instead of std::format
namespace fmt_lib = fmt;
using string_view_t = fmt::basic_string_view<char>;
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
template <typename... Args>
using format_string_t = fmt::format_string<Args...>;
using wstring_view_t = fmt::basic_string_view<wchar_t>;
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
#endif // SPDLOG_USE_STD_FORMAT

View File

@ -192,7 +192,7 @@ protected:
// common implementation for after templated public api has been resolved to format string and
// args
template <typename... Args>
void log_with_format_(source_loc loc, level lvl, string_view_t fmt, Args &&...args) {
void log_with_format_(source_loc loc, level lvl, format_string_t<Args...> fmt, Args &&...args) {
assert(should_log(lvl));
SPDLOG_TRY {
#ifdef SPDLOG_USE_STD_FORMAT