diff --git a/include/spdlog/common.h b/include/spdlog/common.h index f0b2a996..443c058a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -145,7 +145,7 @@ using wmemory_buf_t = std::wstring; template using wformat_string_t = std::wstring_view; # endif - +# define SPDLOG_BUF_TO_STRING(x) x #else // use fmt lib instead of std::format namespace fmt_lib = fmt; @@ -173,6 +173,7 @@ using wmemory_buf_t = fmt::basic_memory_buffer; template using wformat_string_t = fmt::wformat_string; # endif +# define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x) #endif #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT @@ -323,7 +324,7 @@ template using enable_if_t = typename std::enable_if::type; template -std::unique_ptr make_unique(Args &&... args) +std::unique_ptr make_unique(Args &&...args) { static_assert(!std::is_array::value, "arrays not supported"); return std::unique_ptr(new T(std::forward(args)...)); diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index aaefcf83..b9bab53c 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -33,7 +33,6 @@ # if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES) # include -# include # endif # include // for _mkdir/_wmkdir @@ -389,7 +388,7 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { memory_buf_t buf; wstr_to_utf8buf(filename, buf); - return fmt_helper::to_string(std::move(buf)); + return SPDLOG_BUF_TO_STRING(buf); } #else SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) diff --git a/include/spdlog/sinks/ringbuffer_sink.h b/include/spdlog/sinks/ringbuffer_sink.h index 7e0c56d0..d2fc8c49 100644 --- a/include/spdlog/sinks/ringbuffer_sink.h +++ b/include/spdlog/sinks/ringbuffer_sink.h @@ -5,7 +5,6 @@ #include "spdlog/sinks/base_sink.h" #include "spdlog/details/circular_q.h" -#include "spdlog/details/fmt_helper.h" #include "spdlog/details/log_msg_buffer.h" #include "spdlog/details/null_mutex.h" @@ -51,7 +50,7 @@ public: { memory_buf_t formatted; base_sink::formatter_->format(q_.at(i), formatted); - ret.push_back(details::fmt_helper::to_string(std::move(formatted))); + ret.push_back(SPDLOG_BUF_TO_STRING(std::move(formatted))); } return ret; } diff --git a/tests/test_daily_logger.cpp b/tests/test_daily_logger.cpp index a83c4c48..c6e685de 100644 --- a/tests/test_daily_logger.cpp +++ b/tests/test_daily_logger.cpp @@ -10,16 +10,16 @@ using filename_memory_buf_t = fmt::basic_memory_bufferflush(); - require_message_count(filename_buf_to_utf8string(std::move(w)), 10); + require_message_count(filename_buf_to_utf8string(w), 10); } struct custom_daily_file_name_calculator @@ -55,7 +55,7 @@ struct custom_daily_file_name_calculator spdlog::fmt_lib::format_to(std::back_inserter(w), SPDLOG_FILENAME_T("{}{:04d}{:02d}{:02d}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday); - return spdlog::details::fmt_helper::to_string(std::move(w)); + return SPDLOG_BUF_TO_STRING(w); } }; @@ -80,7 +80,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]") logger->flush(); - require_message_count(filename_buf_to_utf8string(std::move(w)), 10); + require_message_count(filename_buf_to_utf8string(w), 10); } /*