Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++17: std::char_traits<>::{compare,length} is constexpr - v2 #2257

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down