diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index 2548cdf..f960d03 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -37,9 +37,7 @@ // Standard version #if __cpp_lib_is_constant_evaluated >= 201811L #define BOOST_STATIC_STRING_IS_CONST_EVAL std::is_constant_evaluated() -#elif defined(__clang__) && BOOST_STATIC_STRING_HAS_BUILTIN(__builtin_is_constant_evaluated) -// If we have clang version 9+, we can use the intrinsic -// While gcc also has this, we don't need it +#elif BOOST_STATIC_STRING_HAS_BUILTIN(__builtin_is_constant_evaluated) #define BOOST_STATIC_STRING_IS_CONST_EVAL __builtin_is_constant_evaluated() #endif diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index c7f4433..a0e447a 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -586,15 +586,8 @@ ptr_in_range( const T* src_last, const T* ptr) { - // We want to make this usable in constant expressions as much as possible - // while retaining the guarentee that the comparison has a strict total ordering. - // We also want this to be fast. Since different compilers have differing levels - // of conformance, we will settle for the best option that is available. - // We don't care about this in C++11, since this function would have - // no applications in constant expressions. #if defined(BOOST_STATIC_STRING_CPP14) && \ -defined(BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS) -#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL +defined(BOOST_STATIC_STRING_IS_CONST_EVAL) // Our second best option is to use is_constant_evaluated // and a loop that checks for equality, since equality for // pointer to object types is never unspecified in this case. @@ -605,17 +598,24 @@ defined(BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS) return true; return false; } -#else - // If library comparison functions don't work, and - // we cannot use any of the above, we can use - // try builtin comparison operators instead. +#endif + // We want to make this usable in constant expressions as much as possible + // while retaining the guarentee that the comparison has a strict total ordering. + // We also want this to be fast. Since different compilers have differing levels + // of conformance, we will settle for the best option that is available. + // We don't care about this in C++11, since this function would have + // no applications in constant expressions. +#if defined(BOOST_STATIC_STRING_CPP14) && \ +defined(BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS) + // If library comparison functions don't work, + // we can use try builtin comparison operators instead. return ptr >= src_first && ptr < src_last; -#endif -#endif +#else // Use the library comparison functions if we can't use // is_constant_evaluated or if we don't need to. return std::greater_equal()(ptr, src_first) && std::less()(ptr, src_last); +#endif } } // detail #endif