File indexing completed on 2025-04-26 08:27:13
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_CORE_POINTER_IN_RANGE_HPP
0009 #define BOOST_CORE_POINTER_IN_RANGE_HPP
0010
0011 #include <boost/config.hpp>
0012 #include <functional>
0013
0014 #if !defined(BOOST_NO_CXX14_CONSTEXPR)
0015 #if defined(BOOST_MSVC) && BOOST_MSVC >= 1925
0016 #define BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL
0017 #elif defined(__has_builtin)
0018 #if __has_builtin(__builtin_is_constant_evaluated)
0019 #define BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL
0020 #endif
0021 #endif
0022 #endif
0023
0024 #if !defined(BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL)
0025 #define BOOST_CORE_NO_CONSTEXPR_POINTER_IN_RANGE
0026 #endif
0027
0028 namespace boost {
0029
0030 template<class T>
0031 inline BOOST_CONSTEXPR bool
0032 pointer_in_range(const T* p, const T* b, const T* e)
0033 {
0034 #if defined(BOOST_CORE_DETAIL_HAS_IS_CONSTEVAL)
0035 if ( __builtin_is_constant_evaluated()) {
0036 for (; b != e; ++b) {
0037 if (b == p) {
0038 return true;
0039 }
0040 }
0041 return false;
0042 }
0043 #endif
0044 return std::less_equal<const T*>()(b, p) && std::less<const T*>()(p, e);
0045 }
0046
0047 }
0048
0049 #endif