From fdd1bd53b8783bede6387b2cccbecf95a9012243 Mon Sep 17 00:00:00 2001 From: "M. Galib Uludag" Date: Mon, 27 Mar 2023 11:03:02 +0200 Subject: [PATCH] added SPDLOG_CONSTEVAL for >=C++20 --- include/spdlog/common.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index d2b39b7a..5bc5e927 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -113,6 +113,20 @@ catch (const std::exception &) {} #endif +#ifdef _MSC_VER +#define SPDLOG_CPLUSPLUS _MSVC_LANG +#else +#define SPDLOG_CPLUSPLUS _cplusplus +#endif + +#if SPDLOG_CPLUSPLUS > 201703L +#define SPDLOG_CONSTEVAL consteval +#elif SPDLOG_CPLUSPLUS < 201402L +#define SPDLOG_CONSTEVAL constexpr +#else +#define SPDLOG_CONSTEVAL +#endif + namespace spdlog { class formatter; @@ -139,7 +153,7 @@ template struct format_string_wrapper { template - SPDLOG_CONSTEXPR format_string_wrapper(S fmt, details::source_location loc = details::source_location::current()) + SPDLOG_CONSTEVAL format_string_wrapper(S fmt, details::source_location loc = details::source_location::current()) : fmt_{fmt} , loc_{loc} {}