C++14 build fixes for older gcc #2333

This commit is contained in:
Kevin Slattery 2022-05-11 15:14:41 -05:00
parent 128cbe5a06
commit 5f5e70e96e
3 changed files with 24 additions and 5 deletions

View File

@ -262,15 +262,16 @@ struct my_type
: i(i){};
};
namespace fmt_lib = spdlog::fmt_lib;
FMTLIB_BEGIN_NAMESPACE
template<>
struct fmt_lib::formatter<my_type> : fmt_lib::formatter<std::string>
struct formatter<my_type> : formatter<std::string>
{
auto format(my_type my, format_context &ctx) -> decltype(ctx.out())
{
return fmt_lib::format_to(ctx.out(), "[my_type i={}]", my.i);
return format_to(ctx.out(), "[my_type i={}]", my.i);
}
};
FMTLIB_END_NAMESPACE
void user_defined_example()
{

View File

@ -126,6 +126,13 @@ 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)>;
#ifdef SPDLOG_USE_STD_FORMAT
# ifndef FMTLIB_BEGIN_NAMESPACE
# define FMTLIB_BEGIN_NAMESPACE \
namespace std {
# define FMTLIB_END_NAMESPACE \
}
# endif
namespace fmt_lib = std;
using string_view_t = std::string_view;
@ -146,7 +153,16 @@ template<typename... Args>
using wformat_string_t = std::wstring_view;
# endif
# define SPDLOG_BUF_TO_STRING(x) x
#else // use fmt lib instead of std::format
# ifndef FMTLIB_BEGIN_NAMESPACE
# define FMTLIB_BEGIN_NAMESPACE \
namespace fmt {
# define FMTLIB_END_NAMESPACE \
}
# endif
namespace fmt_lib = fmt;
using string_view_t = fmt::basic_string_view<char>;

View File

@ -8,8 +8,10 @@
#include <cctype>
#include <spdlog/common.h>
#if defined(__has_include) && __has_include(<version>)
# include <version>
#if defined(__has_include)
# if __has_include(<version>)
# include <version>
# endif
#endif
#if __cpp_lib_span >= 202002L