Skip to content

Commit

Permalink
alwaus use std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Nov 29, 2024
1 parent 62534f2 commit fb3969d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions include/spdlog/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/spdlog/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class SPDLOG_API logger {
// 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
Expand Down

0 comments on commit fb3969d

Please sign in to comment.