diff --git a/Eigen/src/Core/StlIterators.h b/Eigen/src/Core/StlIterators.h index 25d457530..4576cc043 100644 --- a/Eigen/src/Core/StlIterators.h +++ b/Eigen/src/Core/StlIterators.h @@ -325,7 +325,7 @@ class pointer_based_stl_iterator { public: typedef Index difference_type; typedef typename XprType::Scalar value_type; -#if EIGEN_CPLUSPLUS >= 202002L +#if EIGEN_COMP_CXXVER >= 20 && defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L typedef std::conditional_t iterator_category; diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 97cf4f3b8..0facd2690 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -1316,7 +1316,8 @@ inline int queryTopLevelCacheSize() { * This wraps C++20's std::construct_at, using placement new instead if it is not available. */ -#if EIGEN_COMP_CXXVER >= 20 +#if EIGEN_COMP_CXXVER >= 20 && defined(__cpp_lib_constexpr_dynamic_alloc) && \ + __cpp_lib_constexpr_dynamic_alloc >= 201907L using std::construct_at; #else template diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 39a117e2e..40604f8ea 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -220,7 +220,7 @@ struct is_void : is_same> {}; * * Post C++17: Uses std::void_t */ -#if EIGEN_COMP_CXXVER >= 17 +#if EIGEN_COMP_CXXVER >= 17 && defined(__cpp_lib_void_t) && __cpp_lib_void_t >= 201411L using std::void_t; #else template @@ -338,7 +338,16 @@ struct array_size> { * * For C++20, this function just forwards to `std::ssize`, or any ADL discoverable `ssize` function. */ -#if EIGEN_COMP_CXXVER < 20 || EIGEN_GNUC_STRICT_LESS_THAN(10, 0, 0) +#if EIGEN_COMP_CXXVER >= 20 && defined(__cpp_lib_ssize) && __cpp_lib_ssize >= 201902L + +template +EIGEN_CONSTEXPR auto index_list_size(T&& x) { + using std::ssize; + return ssize(std::forward(x)); +} + +#else + template EIGEN_CONSTEXPR auto index_list_size(const T& x) { using R = std::common_type_t>; @@ -349,13 +358,7 @@ template EIGEN_CONSTEXPR std::ptrdiff_t index_list_size(const T (&)[N]) { return N; } -#else -template -EIGEN_CONSTEXPR auto index_list_size(T&& x) { - using std::ssize; - return ssize(std::forward(x)); -} -#endif // EIGEN_COMP_CXXVER +#endif /** \internal * Convenient struct to get the result type of a nullary, unary, binary, or @@ -745,7 +748,7 @@ inline constexpr bool logical_xor(bool a, bool b) { return a != b; } inline constexpr bool check_implication(bool a, bool b) { return !a || b; } /// \internal Provide fallback for std::is_constant_evaluated for pre-C++20. -#if EIGEN_COMP_CXXVER >= 20 +#if EIGEN_COMP_CXXVER >= 20 && defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L using std::is_constant_evaluated; #else constexpr bool is_constant_evaluated() { return false; }