Skip to content

Commit 0cd0fb9

Browse files
phprusvitaut
authored andcommitted
C++17: std::char_traits<>::{compare,length} is constexpr - v2
1 parent d1a6e56 commit 0cd0fb9

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

include/fmt/core.h

+18-5
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,27 @@
4444
#endif
4545

4646
// Check if constexpr std::char_traits<>::compare,length is supported.
47-
// libstdc++: present on GCC 7 and newer and __cplusplus >= 201703L
48-
// MSVC, libc++: always if __cplusplus >= 201703L
47+
//
48+
// libstdc++: GCC 7 and newer and __cplusplus >= 201703L
49+
// MSVC : VS 2017 15.7 and newer and /std:c++17
50+
// https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance
51+
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
52+
// libc++ : 4.0 and newer and if __cplusplus >= 201703L
53+
// https://libcxx.llvm.org/docs/Cxx1zStatus.html
54+
//
4955
// NOTE: FMT_GCC_VERSION - is not libstdc++ version.
5056
// _GLIBCXX_RELEASE - is present in GCC 7 libstdc++ and newer.
51-
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
52-
# ifndef __GLIBCXX__
57+
#if defined(_MSC_VER)
58+
# if _MSVC_LANG >= 201703L && _MSC_VER >= 1914
5359
# define FMT_CONSTEXPR_CHAR_TRAITS constexpr
54-
# elif defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 7
60+
# endif
61+
#elif defined(_LIBCPP_VERSION)
62+
# if __cplusplus >= 201703L && _LIBCPP_VERSION >= 4000
63+
# define FMT_CONSTEXPR_CHAR_TRAITS constexpr
64+
# endif
65+
#elif defined(__GLIBCXX__)
66+
# if __cplusplus >= 201703L && defined(_GLIBCXX_RELEASE) && \
67+
_GLIBCXX_RELEASE >= 7
5568
# define FMT_CONSTEXPR_CHAR_TRAITS constexpr
5669
# endif
5770
#endif

0 commit comments

Comments
 (0)