Replace instances of EIGEN_CONSTEXPR macro

This commit is contained in:
Tyler Veness
2024-11-15 21:11:01 -08:00
parent 33f5f59614
commit d6689a15d7
78 changed files with 445 additions and 501 deletions

View File

@@ -248,15 +248,15 @@ namespace internal {
#endif
template <std::size_t I_, class T, std::size_t N>
constexpr inline T& array_get(std::array<T, N>& a) {
constexpr T& array_get(std::array<T, N>& a) {
return (T&)STD_GET_ARR_HACK;
}
template <std::size_t I_, class T, std::size_t N>
constexpr inline T&& array_get(std::array<T, N>&& a) {
constexpr T&& array_get(std::array<T, N>&& a) {
return (T&&)STD_GET_ARR_HACK;
}
template <std::size_t I_, class T, std::size_t N>
constexpr inline T const& array_get(std::array<T, N> const& a) {
constexpr T const& array_get(std::array<T, N> const& a) {
return (T const&)STD_GET_ARR_HACK;
}

View File

@@ -337,7 +337,7 @@ struct array_size<std::array<T, N>> {
#if EIGEN_COMP_CXXVER >= 20 && defined(__cpp_lib_ssize) && __cpp_lib_ssize >= 201902L
template <typename T>
EIGEN_CONSTEXPR auto index_list_size(T&& x) {
constexpr auto index_list_size(T&& x) {
using std::ssize;
return ssize(std::forward<T>(x));
}
@@ -345,13 +345,13 @@ EIGEN_CONSTEXPR auto index_list_size(T&& x) {
#else
template <typename T>
EIGEN_CONSTEXPR auto index_list_size(const T& x) {
constexpr auto index_list_size(const T& x) {
using R = std::common_type_t<std::ptrdiff_t, std::make_signed_t<decltype(x.size())>>;
return static_cast<R>(x.size());
}
template <typename T, std::ptrdiff_t N>
EIGEN_CONSTEXPR std::ptrdiff_t index_list_size(const T (&)[N]) {
constexpr std::ptrdiff_t index_list_size(const T (&)[N]) {
return N;
}
#endif
@@ -637,21 +637,21 @@ template <typename A>
constexpr bool is_int_or_enum_v = std::is_enum<A>::value || std::is_integral<A>::value;
template <typename A, typename B>
inline constexpr void plain_enum_asserts(A, B) {
constexpr void plain_enum_asserts(A, B) {
static_assert(is_int_or_enum_v<A>, "Argument a must be an integer or enum");
static_assert(is_int_or_enum_v<B>, "Argument b must be an integer or enum");
}
/// \internal Gets the minimum of two values which may be integers or enums
template <typename A, typename B>
inline constexpr int plain_enum_min(A a, B b) {
constexpr int plain_enum_min(A a, B b) {
plain_enum_asserts(a, b);
return ((int)a <= (int)b) ? (int)a : (int)b;
}
/// \internal Gets the maximum of two values which may be integers or enums
template <typename A, typename B>
inline constexpr int plain_enum_max(A a, B b) {
constexpr int plain_enum_max(A a, B b) {
plain_enum_asserts(a, b);
return ((int)a >= (int)b) ? (int)a : (int)b;
}
@@ -663,7 +663,7 @@ inline constexpr int plain_enum_max(A a, B b) {
* finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
*/
template <typename A, typename B>
inline constexpr int min_size_prefer_dynamic(A a, B b) {
constexpr int min_size_prefer_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == 0 || (int)b == 0) return 0;
if ((int)a == 1 || (int)b == 1) return 1;
@@ -678,7 +678,7 @@ inline constexpr int min_size_prefer_dynamic(A a, B b) {
* 0 and 3), it is not more than 3.
*/
template <typename A, typename B>
inline constexpr int min_size_prefer_fixed(A a, B b) {
constexpr int min_size_prefer_fixed(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == 0 || (int)b == 0) return 0;
if ((int)a == 1 || (int)b == 1) return 1;
@@ -690,7 +690,7 @@ inline constexpr int min_size_prefer_fixed(A a, B b) {
/// \internal see `min_size_prefer_fixed`. No need for a separate variant for MaxSizes here.
template <typename A, typename B>
inline constexpr int max_size_prefer_dynamic(A a, B b) {
constexpr int max_size_prefer_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == Dynamic || (int)b == Dynamic) return Dynamic;
return plain_enum_max(a, b);
@@ -710,38 +710,38 @@ inline constexpr bool enum_eq_not_dynamic(A a, B b) {
}
template <typename A, typename B>
inline constexpr bool enum_lt_not_dynamic(A a, B b) {
constexpr bool enum_lt_not_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == Dynamic || (int)b == Dynamic) return false;
return (int)a < (int)b;
}
template <typename A, typename B>
inline constexpr bool enum_le_not_dynamic(A a, B b) {
constexpr bool enum_le_not_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == Dynamic || (int)b == Dynamic) return false;
return (int)a <= (int)b;
}
template <typename A, typename B>
inline constexpr bool enum_gt_not_dynamic(A a, B b) {
constexpr bool enum_gt_not_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == Dynamic || (int)b == Dynamic) return false;
return (int)a > (int)b;
}
template <typename A, typename B>
inline constexpr bool enum_ge_not_dynamic(A a, B b) {
constexpr bool enum_ge_not_dynamic(A a, B b) {
plain_enum_asserts(a, b);
if ((int)a == Dynamic || (int)b == Dynamic) return false;
return (int)a >= (int)b;
}
/// \internal Calculate logical XOR at compile time
inline constexpr bool logical_xor(bool a, bool b) { return a != b; }
constexpr bool logical_xor(bool a, bool b) { return a != b; }
/// \internal Calculate logical IMPLIES at compile time
inline constexpr bool check_implication(bool a, bool b) { return !a || b; }
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 && defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L

View File

@@ -40,7 +40,7 @@ struct get_compiletime_reshape_size<AutoSize_t, OtherSize, TotalSize> {
inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { return total / other; }
constexpr inline int get_compiletime_reshape_order(int flags, int order) {
constexpr int get_compiletime_reshape_order(int flags, int order) {
return order == AutoOrder ? flags & RowMajorBit : order;
}

View File

@@ -158,8 +158,8 @@ class variable_if_dynamic {
EIGEN_ONLY_USED_FOR_DEBUG(v);
eigen_assert(v == T(Value));
}
EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value() { return T(Value); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR operator T() const { return T(Value); }
EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE constexpr T value() { return T(Value); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr operator T() const { return T(Value); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T v) const {
EIGEN_ONLY_USED_FOR_DEBUG(v);
eigen_assert(v == T(Value));
@@ -186,7 +186,7 @@ class variable_if_dynamicindex {
EIGEN_ONLY_USED_FOR_DEBUG(v);
eigen_assert(v == T(Value));
}
EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value() { return T(Value); }
EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE constexpr T value() { return T(Value); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T) {}
};
@@ -315,7 +315,7 @@ struct find_packet_by_size<T, 1> {
};
#if EIGEN_MAX_STATIC_ALIGN_BYTES > 0
constexpr inline int compute_default_alignment_helper(int ArrayBytes, int AlignmentBytes) {
constexpr int compute_default_alignment_helper(int ArrayBytes, int AlignmentBytes) {
if ((ArrayBytes % AlignmentBytes) == 0) {
return AlignmentBytes;
} else if (EIGEN_MIN_ALIGN_BYTES < AlignmentBytes) {
@@ -327,7 +327,7 @@ constexpr inline int compute_default_alignment_helper(int ArrayBytes, int Alignm
#else
// If static alignment is disabled, no need to bother.
// This also avoids a division by zero
constexpr inline int compute_default_alignment_helper(int ArrayBytes, int AlignmentBytes) {
constexpr int compute_default_alignment_helper(int ArrayBytes, int AlignmentBytes) {
EIGEN_UNUSED_VARIABLE(ArrayBytes);
EIGEN_UNUSED_VARIABLE(AlignmentBytes);
return 0;
@@ -362,7 +362,7 @@ class make_proper_matrix_type {
typedef Matrix<Scalar_, Rows_, Cols_, Options, MaxRows_, MaxCols_> type;
};
constexpr inline unsigned compute_matrix_flags(int Options) {
constexpr unsigned compute_matrix_flags(int Options) {
unsigned row_major_bit = Options & RowMajor ? RowMajorBit : 0;
// FIXME currently we still have to handle DirectAccessBit at the expression level to handle DenseCoeffsBase<>
// and then propagate this information to the evaluator's flags.
@@ -370,7 +370,7 @@ constexpr inline unsigned compute_matrix_flags(int Options) {
return DirectAccessBit | LvalueBit | NestByRefBit | row_major_bit;
}
constexpr inline int size_at_compile_time(int rows, int cols) {
constexpr int size_at_compile_time(int rows, int cols) {
if (rows == 0 || cols == 0) return 0;
if (rows == Dynamic || cols == Dynamic) return Dynamic;
return rows * cols;