diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 210f8de3..771c9a35 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -148,61 +148,23 @@ struct source_loc const char *funcname{nullptr}; }; -template +template struct format_string_wrapper { - template - SPDLOG_CONSTEVAL format_string_wrapper(S fmtstr, details::source_location loc = details::source_location::current()) + SPDLOG_CONSTEVAL format_string_wrapper(const Char* fmtstr, details::source_location loc = details::source_location::current()) : fmt_{fmtstr} , loc_{loc} {} -#if SPDLOG_CPLUSPLUS > 201703L #if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 - format_string_wrapper(fmt::basic_runtime fmtstr, details::source_location loc = details::source_location::current()) + SPDLOG_CONSTEXPR format_string_wrapper(fmt::basic_runtime fmtstr, details::source_location loc = details::source_location::current()) : fmt_{fmtstr} , loc_{loc} {} #else - explicit format_string_wrapper(const char* fmtstr, details::source_location loc = details::source_location::current()) + SPDLOG_CONSTEXPR format_string_wrapper(const Char* fmtstr, details::source_location loc = details::source_location::current()) : fmt_{fmtstr} , loc_{loc} {} -#endif -#endif - T fmt() - { - return fmt_; - } - source_loc loc() - { - return source_loc{loc_.file_name(), loc_.line(), loc_.function_name()}; - } - -private: - T fmt_; - spdlog::details::source_location loc_; -}; - -template -struct wformat_string_wrapper -{ - template - SPDLOG_CONSTEVAL wformat_string_wrapper(S fmtstr, details::source_location loc = details::source_location::current()) - : fmt_{fmtstr} - , loc_{loc} - {} -#if SPDLOG_CPLUSPLUS > 201703L -#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 - wformat_string_wrapper(fmt::basic_runtime fmtstr, details::source_location loc = details::source_location::current()) - : fmt_{fmtstr} - , loc_{loc} - {} -#else - explicit wformat_string_wrapper(const wchar_t* fmtstr, details::source_location loc = details::source_location::current()) - : fmt_{fmtstr} - , loc_{loc} - {} -#endif #endif T fmt() { @@ -245,9 +207,9 @@ using memory_buf_t = std::string; template # if __cpp_lib_format >= 202207L -using format_string_t = format_string_wrapper>; +using format_string_t = format_string_wrapper, char>; # else -using format_string_t = format_string_wrapper; +using format_string_t = format_string_wrapper; # endif @@ -261,9 +223,9 @@ using wmemory_buf_t = std::wstring; template # if __cpp_lib_format >= 202207L -using wformat_string_t = wformat_string_wrapper>; +using wformat_string_t = format_string_wrapper, wchar_t>; # else -using wformat_string_t = wformat_string_wrapper; +using wformat_string_t = format_string_wrapper; # endif # endif # define SPDLOG_BUF_TO_STRING(x) x @@ -274,7 +236,7 @@ using string_view_t = fmt::basic_string_view; using memory_buf_t = fmt::basic_memory_buffer; template -using format_string_t = format_string_wrapper>; +using format_string_t = format_string_wrapper, char>; template using remove_cvref_t = typename std::remove_cv::type>::type; @@ -292,7 +254,7 @@ using wstring_view_t = fmt::basic_string_view; using wmemory_buf_t = fmt::basic_memory_buffer; template -using wformat_string_t = wformat_string_wrapper>; +using wformat_string_t = format_string_wrapper, wchar_t>; # endif # define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x) #endif