From 0cd0fb91840edbaf1a1ed2cbfbe3c23e76b63f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A9=D0=B0=D0=BF=D0=BE=D0=B2?= Date: Tue, 27 Apr 2021 18:53:10 +0500 Subject: [PATCH] C++17: std::char_traits<>::{compare,length} is constexpr - v2 --- include/fmt/core.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index a7f9e4b2..75304d04 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -44,14 +44,27 @@ #endif // Check if constexpr std::char_traits<>::compare,length is supported. -// libstdc++: present on GCC 7 and newer and __cplusplus >= 201703L -// MSVC, libc++: always if __cplusplus >= 201703L +// +// libstdc++: GCC 7 and newer and __cplusplus >= 201703L +// MSVC : VS 2017 15.7 and newer and /std:c++17 +// https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance +// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros +// libc++ : 4.0 and newer and if __cplusplus >= 201703L +// https://libcxx.llvm.org/docs/Cxx1zStatus.html +// // NOTE: FMT_GCC_VERSION - is not libstdc++ version. // _GLIBCXX_RELEASE - is present in GCC 7 libstdc++ and newer. -#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# ifndef __GLIBCXX__ +#if defined(_MSC_VER) +# if _MSVC_LANG >= 201703L && _MSC_VER >= 1914 # define FMT_CONSTEXPR_CHAR_TRAITS constexpr -# elif defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 7 +# endif +#elif defined(_LIBCPP_VERSION) +# if __cplusplus >= 201703L && _LIBCPP_VERSION >= 4000 +# define FMT_CONSTEXPR_CHAR_TRAITS constexpr +# endif +#elif defined(__GLIBCXX__) +# if __cplusplus >= 201703L && defined(_GLIBCXX_RELEASE) && \ + _GLIBCXX_RELEASE >= 7 # define FMT_CONSTEXPR_CHAR_TRAITS constexpr # endif #endif