From 7b5ef2dfe9433c0d4d3580c855945e8b79d223eb Mon Sep 17 00:00:00 2001 From: Elliot Haisley <35050275+Apache-HB@users.noreply.github.com> Date: Mon, 5 Apr 2021 10:14:26 -0400 Subject: [PATCH] use const_check --- include/fmt/core.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 73a3b0d3..f1684657 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -98,13 +98,6 @@ # define FMT_CONSTEXPR_DECL #endif -// C++17's char_traits::length() is constexpr. -#if __cplusplus >= 201703L -# define FMT_CONSTEXPR_CHAR_TRAITS_LENGTH FMT_CONSTEXPR -#else -# define FMT_CONSTEXPR_CHAR_TRAITS_LENGTH -#endif - #ifndef FMT_OVERRIDE # if FMT_HAS_FEATURE(cxx_override_control) || \ (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 @@ -399,8 +392,12 @@ template class basic_string_view { the size with ``std::char_traits::length``. \endrst */ - FMT_CONSTEXPR_CHAR_TRAITS_LENGTH FMT_INLINE basic_string_view(const Char* s) : data_(s) { - if FMT_CONSTEXPR_CHAR_TRAITS_LENGTH (std::is_same::value && !detail::is_constant_evaluated()) +// C++17's char_traits::length() is constexpr. +#if __cplusplus >= 201703L + constexpr +#endif + FMT_INLINE basic_string_view(const Char* s) : data_(s) { + if (detail::const_check(std::is_same::value && !detail::is_constant_evaluated())) size_ = std::strlen(reinterpret_cast(s)); else size_ = std::char_traits::length(s);