mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 03:19:02 +08:00
Support C++20 std::format as an alternative to fmtlib
This commit is contained in:
@@ -74,12 +74,8 @@ inline details::dump_info<It> to_hex(const It range_begin, const It range_end, s
|
||||
return details::dump_info<It>(range_begin, range_end, size_per_line);
|
||||
}
|
||||
|
||||
} // namespace spdlog
|
||||
|
||||
namespace fmt {
|
||||
|
||||
template<typename T>
|
||||
struct formatter<spdlog::details::dump_info<T>>
|
||||
struct fmt_lib::formatter<spdlog::details::dump_info<T>, char>
|
||||
{
|
||||
const char delimiter = ' ';
|
||||
bool put_newlines = true;
|
||||
@@ -90,7 +86,7 @@ struct formatter<spdlog::details::dump_info<T>>
|
||||
|
||||
// parse the format string flags
|
||||
template<typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext &ctx) -> decltype(ctx.begin())
|
||||
SPDLOG_CONSTEXPR auto parse(ParseContext &ctx) -> decltype(ctx.begin())
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
while (it != ctx.end() && *it != '}')
|
||||
@@ -210,8 +206,8 @@ struct formatter<spdlog::details::dump_info<T>>
|
||||
|
||||
if (put_positions)
|
||||
{
|
||||
fmt::format_to(inserter, "{:04X}: ", pos);
|
||||
fmt_lib::format_to(inserter, "{:04X}: ", pos);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace fmt
|
||||
} // namespace spdlog
|
||||
|
@@ -8,13 +8,15 @@
|
||||
// include bundled or external copy of fmtlib's chrono support
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
||||
# if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/chrono.h>
|
||||
# else
|
||||
# include <fmt/chrono.h>
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/chrono.h>
|
||||
#else
|
||||
# include <fmt/chrono.h>
|
||||
#endif
|
||||
|
@@ -5,16 +5,18 @@
|
||||
|
||||
#pragma once
|
||||
//
|
||||
// include bundled or external copy of fmtlib's ostream support
|
||||
// include bundled or external copy of fmtlib's compile-time support
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
||||
# if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/compile.h>
|
||||
# else
|
||||
# include <fmt/compile.h>
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/compile.h>
|
||||
#else
|
||||
# include <fmt/compile.h>
|
||||
#endif
|
||||
|
@@ -10,7 +10,9 @@
|
||||
// By default spdlog include its own copy.
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
#if defined(SPDLOG_USE_STD_FORMAT) // SPDLOG_USE_STD_FORMAT is defined - use std::format
|
||||
# include <format>
|
||||
#elif !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY)
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
|
@@ -8,13 +8,15 @@
|
||||
// include bundled or external copy of fmtlib's ostream support
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
||||
# if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/ostream.h>
|
||||
# else
|
||||
# include <fmt/ostream.h>
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/ostream.h>
|
||||
#else
|
||||
# include <fmt/ostream.h>
|
||||
#endif
|
||||
|
@@ -5,16 +5,18 @@
|
||||
|
||||
#pragma once
|
||||
//
|
||||
// include bundled or external copy of fmtlib's ostream support
|
||||
// include bundled or external copy of fmtlib's xchar support
|
||||
//
|
||||
|
||||
#if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT)
|
||||
# if !defined(SPDLOG_FMT_EXTERNAL)
|
||||
# ifdef SPDLOG_HEADER_ONLY
|
||||
# ifndef FMT_HEADER_ONLY
|
||||
# define FMT_HEADER_ONLY
|
||||
# endif
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/xchar.h>
|
||||
# else
|
||||
# include <fmt/xchar.h>
|
||||
# endif
|
||||
# include <spdlog/fmt/bundled/xchar.h>
|
||||
#else
|
||||
# include <fmt/xchar.h>
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user