mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix STL feature detection for c++20.
This commit is contained in:
parent
179a49684a
commit
be5147b090
@ -325,7 +325,7 @@ class pointer_based_stl_iterator {
|
|||||||
public:
|
public:
|
||||||
typedef Index difference_type;
|
typedef Index difference_type;
|
||||||
typedef typename XprType::Scalar value_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<XprType::InnerStrideAtCompileTime == 1, std::contiguous_iterator_tag,
|
typedef std::conditional_t<XprType::InnerStrideAtCompileTime == 1, std::contiguous_iterator_tag,
|
||||||
std::random_access_iterator_tag>
|
std::random_access_iterator_tag>
|
||||||
iterator_category;
|
iterator_category;
|
||||||
|
@ -1316,7 +1316,8 @@ inline int queryTopLevelCacheSize() {
|
|||||||
* This wraps C++20's std::construct_at, using placement new instead if it is not available.
|
* 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;
|
using std::construct_at;
|
||||||
#else
|
#else
|
||||||
template <class T, class... Args>
|
template <class T, class... Args>
|
||||||
|
@ -220,7 +220,7 @@ struct is_void : is_same<void, std::remove_const_t<T>> {};
|
|||||||
*
|
*
|
||||||
* Post C++17: Uses std::void_t
|
* 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;
|
using std::void_t;
|
||||||
#else
|
#else
|
||||||
template <typename...>
|
template <typename...>
|
||||||
@ -338,7 +338,16 @@ struct array_size<std::array<T, N>> {
|
|||||||
*
|
*
|
||||||
* For C++20, this function just forwards to `std::ssize`, or any ADL discoverable `ssize` function.
|
* 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 <typename T>
|
||||||
|
EIGEN_CONSTEXPR auto index_list_size(T&& x) {
|
||||||
|
using std::ssize;
|
||||||
|
return ssize(std::forward<T>(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
EIGEN_CONSTEXPR auto index_list_size(const T& x) {
|
EIGEN_CONSTEXPR auto index_list_size(const T& x) {
|
||||||
using R = std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(x.size())>>;
|
using R = std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(x.size())>>;
|
||||||
@ -349,13 +358,7 @@ template <typename T, std::ptrdiff_t N>
|
|||||||
EIGEN_CONSTEXPR std::ptrdiff_t index_list_size(const T (&)[N]) {
|
EIGEN_CONSTEXPR std::ptrdiff_t index_list_size(const T (&)[N]) {
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
template <typename T>
|
|
||||||
EIGEN_CONSTEXPR auto index_list_size(T&& x) {
|
|
||||||
using std::ssize;
|
|
||||||
return ssize(std::forward<T>(x));
|
|
||||||
}
|
|
||||||
#endif // EIGEN_COMP_CXXVER
|
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* Convenient struct to get the result type of a nullary, unary, binary, or
|
* 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; }
|
inline constexpr bool check_implication(bool a, bool b) { return !a || b; }
|
||||||
|
|
||||||
/// \internal Provide fallback for std::is_constant_evaluated for pre-C++20.
|
/// \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;
|
using std::is_constant_evaluated;
|
||||||
#else
|
#else
|
||||||
constexpr bool is_constant_evaluated() { return false; }
|
constexpr bool is_constant_evaluated() { return false; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user