Remove redundant EIGEN_STRONG_INLINE from trivial constexpr and = default functions

libeigen/eigen!2161

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-20 19:50:52 -08:00
parent e0a8d6c9d8
commit 270ea539fa
26 changed files with 274 additions and 333 deletions

View File

@@ -1033,7 +1033,7 @@
namespace Eigen {
namespace internal {
template <typename T>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void ignore_unused_variable(const T&) {}
EIGEN_DEVICE_FUNC constexpr void ignore_unused_variable(const T&) {}
} // namespace internal
} // namespace Eigen
#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);

View File

@@ -116,17 +116,17 @@ class MaxSizeVector {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool empty() const { return size_ == 0; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* data() { return data_; }
EIGEN_DEVICE_FUNC constexpr T* data() { return data_; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* data() const { return data_; }
EIGEN_DEVICE_FUNC constexpr const T* data() const { return data_; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* begin() { return data_; }
EIGEN_DEVICE_FUNC constexpr T* begin() { return data_; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr T* end() { return data_ + size_; }
EIGEN_DEVICE_FUNC constexpr T* end() { return data_ + size_; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* begin() const { return data_; }
EIGEN_DEVICE_FUNC constexpr const T* begin() const { return data_; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const T* end() const { return data_ + size_; }
EIGEN_DEVICE_FUNC constexpr const T* end() const { return data_ + size_; }
private:
size_t reserve_;

View File

@@ -1355,15 +1355,13 @@ EIGEN_DEVICE_FUNC void destroy_at(T* p) {
#endif
// FIXME(rmlarsen): Work around missing linker symbol with msan on ARM.
#if !defined(EIGEN_DONT_ASSUME_ALIGNED) && __has_feature(memory_sanitizer) && \
(EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64)
#if !defined(EIGEN_DONT_ASSUME_ALIGNED) && __has_feature(memory_sanitizer) && (EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64)
#define EIGEN_DONT_ASSUME_ALIGNED
#endif
#if !defined(EIGEN_DONT_ASSUME_ALIGNED) && defined(__cpp_lib_assume_aligned) && (__cpp_lib_assume_aligned >= 201811L)
template <std::size_t N, typename T>
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr T* assume_aligned(T* ptr) {
EIGEN_DEVICE_FUNC constexpr T* assume_aligned(T* ptr) {
return std::assume_aligned<N, T>(ptr);
}
#elif !defined(EIGEN_DONT_ASSUME_ALIGNED) && EIGEN_HAS_BUILTIN(__builtin_assume_aligned)
@@ -1373,7 +1371,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC T* assume_aligned(T* ptr) {
}
#else
template <std::size_t N, typename T>
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr T* assume_aligned(T* ptr) {
EIGEN_DEVICE_FUNC constexpr T* assume_aligned(T* ptr) {
return ptr;
}
#endif

View File

@@ -186,12 +186,11 @@ struct h_skip_helper_type<0> {
template <int n>
struct h_skip {
template <typename T, T... ii>
constexpr static EIGEN_STRONG_INLINE typename h_skip_helper_numeric<T, n, ii...>::type helper(
numeric_list<T, ii...>) {
constexpr static typename h_skip_helper_numeric<T, n, ii...>::type helper(numeric_list<T, ii...>) {
return typename h_skip_helper_numeric<T, n, ii...>::type();
}
template <typename... tt>
constexpr static EIGEN_STRONG_INLINE typename h_skip_helper_type<n, tt...>::type helper(type_list<tt...>) {
constexpr static typename h_skip_helper_type<n, tt...>::type helper(type_list<tt...>) {
return typename h_skip_helper_type<n, tt...>::type();
}
};
@@ -330,17 +329,17 @@ struct reduce;
template <typename Reducer>
struct reduce<Reducer> {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE int run() { return Reducer::Identity; }
EIGEN_DEVICE_FUNC constexpr static int run() { return Reducer::Identity; }
};
template <typename Reducer, typename A>
struct reduce<Reducer, A> {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE A run(A a) { return a; }
EIGEN_DEVICE_FUNC constexpr static A run(A a) { return a; }
};
template <typename Reducer, typename A, typename... Ts>
struct reduce<Reducer, A, Ts...> {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, Ts... ts)
EIGEN_DEVICE_FUNC constexpr static auto run(A a, Ts... ts)
-> decltype(Reducer::run(a, reduce<Reducer, Ts...>::run(ts...))) {
return Reducer::run(a, reduce<Reducer, Ts...>::run(ts...));
}
@@ -350,14 +349,14 @@ struct reduce<Reducer, A, Ts...> {
struct sum_op {
template <typename A, typename B>
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a + b) {
EIGEN_DEVICE_FUNC constexpr static auto run(A a, B b) -> decltype(a + b) {
return a + b;
}
static constexpr int Identity = 0;
};
struct product_op {
template <typename A, typename B>
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a * b) {
EIGEN_DEVICE_FUNC constexpr static auto run(A a, B b) -> decltype(a * b) {
return a * b;
}
static constexpr int Identity = 1;
@@ -365,50 +364,50 @@ struct product_op {
struct logical_and_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a && b) {
constexpr static auto run(A a, B b) -> decltype(a && b) {
return a && b;
}
};
struct logical_or_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a || b) {
constexpr static auto run(A a, B b) -> decltype(a || b) {
return a || b;
}
};
struct equal_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a == b) {
constexpr static auto run(A a, B b) -> decltype(a == b) {
return a == b;
}
};
struct not_equal_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a != b) {
constexpr static auto run(A a, B b) -> decltype(a != b) {
return a != b;
}
};
struct lesser_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a < b) {
constexpr static auto run(A a, B b) -> decltype(a < b) {
return a < b;
}
};
struct lesser_equal_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a <= b) {
constexpr static auto run(A a, B b) -> decltype(a <= b) {
return a <= b;
}
};
struct greater_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a > b) {
constexpr static auto run(A a, B b) -> decltype(a > b) {
return a > b;
}
};
struct greater_equal_op {
template <typename A, typename B>
constexpr static EIGEN_STRONG_INLINE auto run(A a, B b) -> decltype(a >= b) {
constexpr static auto run(A a, B b) -> decltype(a >= b) {
return a >= b;
}
};
@@ -417,19 +416,19 @@ struct greater_equal_op {
struct not_op {
template <typename A>
constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(!a) {
constexpr static auto run(A a) -> decltype(!a) {
return !a;
}
};
struct negation_op {
template <typename A>
constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(-a) {
constexpr static auto run(A a) -> decltype(-a) {
return -a;
}
};
struct greater_equal_zero_op {
template <typename A>
constexpr static EIGEN_STRONG_INLINE auto run(A a) -> decltype(a >= 0) {
constexpr static auto run(A a) -> decltype(a >= 0) {
return a >= 0;
}
};
@@ -440,25 +439,24 @@ struct greater_equal_zero_op {
// together in front... (13.0 doesn't work with array_prod/array_reduce/... anyway, but 13.1
// does...
template <typename... Ts>
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE decltype(reduce<product_op, Ts...>::run((*((Ts*)0))...)) arg_prod(
Ts... ts) {
EIGEN_DEVICE_FUNC constexpr decltype(reduce<product_op, Ts...>::run((*((Ts*)0))...)) arg_prod(Ts... ts) {
return reduce<product_op, Ts...>::run(ts...);
}
template <typename... Ts>
constexpr EIGEN_STRONG_INLINE decltype(reduce<sum_op, Ts...>::run((*((Ts*)0))...)) arg_sum(Ts... ts) {
constexpr decltype(reduce<sum_op, Ts...>::run((*((Ts*)0))...)) arg_sum(Ts... ts) {
return reduce<sum_op, Ts...>::run(ts...);
}
/* reverse arrays */
template <typename Array, int... n>
constexpr EIGEN_STRONG_INLINE Array h_array_reverse(Array arr, numeric_list<int, n...>) {
constexpr Array h_array_reverse(Array arr, numeric_list<int, n...>) {
return {{array_get<sizeof...(n) - n - 1>(arr)...}};
}
template <typename T, std::size_t N>
constexpr EIGEN_STRONG_INLINE array<T, N> array_reverse(array<T, N> arr) {
constexpr array<T, N> array_reverse(array<T, N> arr) {
return h_array_reverse(arr, typename gen_numeric_list<int, N>::type());
}
@@ -471,7 +469,7 @@ constexpr EIGEN_STRONG_INLINE array<T, N> array_reverse(array<T, N> arr) {
// an infinite loop)
template <typename Reducer, typename T, std::size_t N, std::size_t n = N - 1>
struct h_array_reduce {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE auto run(array<T, N> arr, T identity)
EIGEN_DEVICE_FUNC constexpr static auto run(array<T, N> arr, T identity)
-> decltype(Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr))) {
return Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr));
}
@@ -479,16 +477,16 @@ struct h_array_reduce {
template <typename Reducer, typename T, std::size_t N>
struct h_array_reduce<Reducer, T, N, 0> {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE T run(const array<T, N>& arr, T) { return array_get<0>(arr); }
EIGEN_DEVICE_FUNC constexpr static T run(const array<T, N>& arr, T) { return array_get<0>(arr); }
};
template <typename Reducer, typename T>
struct h_array_reduce<Reducer, T, 0> {
EIGEN_DEVICE_FUNC constexpr static EIGEN_STRONG_INLINE T run(const array<T, 0>&, T identity) { return identity; }
EIGEN_DEVICE_FUNC constexpr static T run(const array<T, 0>&, T identity) { return identity; }
};
template <typename Reducer, typename T, std::size_t N>
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_reduce(const array<T, N>& arr, T identity)
EIGEN_DEVICE_FUNC constexpr auto array_reduce(const array<T, N>& arr, T identity)
-> decltype(h_array_reduce<Reducer, T, N>::run(arr, identity)) {
return h_array_reduce<Reducer, T, N>::run(arr, identity);
}
@@ -496,13 +494,13 @@ EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_reduce(const array<T,
/* standard array reductions */
template <typename T, std::size_t N>
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_sum(const array<T, N>& arr)
EIGEN_DEVICE_FUNC constexpr auto array_sum(const array<T, N>& arr)
-> decltype(array_reduce<sum_op, T, N>(arr, static_cast<T>(0))) {
return array_reduce<sum_op, T, N>(arr, static_cast<T>(0));
}
template <typename T, std::size_t N>
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE auto array_prod(const array<T, N>& arr)
EIGEN_DEVICE_FUNC constexpr auto array_prod(const array<T, N>& arr)
-> decltype(array_reduce<product_op, T, N>(arr, static_cast<T>(1))) {
return array_reduce<product_op, T, N>(arr, static_cast<T>(1));
}
@@ -520,20 +518,19 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const std::vector<t>& a) {
/* zip an array */
template <typename Op, typename A, typename B, std::size_t N, int... n>
constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A(), B())), N> h_array_zip(array<A, N> a, array<B, N> b,
numeric_list<int, n...>) {
constexpr array<decltype(Op::run(A(), B())), N> h_array_zip(array<A, N> a, array<B, N> b, numeric_list<int, n...>) {
return array<decltype(Op::run(A(), B())), N>{{Op::run(array_get<n>(a), array_get<n>(b))...}};
}
template <typename Op, typename A, typename B, std::size_t N>
constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A(), B())), N> array_zip(array<A, N> a, array<B, N> b) {
constexpr array<decltype(Op::run(A(), B())), N> array_zip(array<A, N> a, array<B, N> b) {
return h_array_zip<Op>(a, b, typename gen_numeric_list<int, N>::type());
}
/* zip an array and reduce the result */
template <typename Reducer, typename Op, typename A, typename B, std::size_t N, int... n>
constexpr EIGEN_STRONG_INLINE auto h_array_zip_and_reduce(array<A, N> a, array<B, N> b, numeric_list<int, n...>)
constexpr auto h_array_zip_and_reduce(array<A, N> a, array<B, N> b, numeric_list<int, n...>)
-> decltype(reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A(), B()))>::type...>::run(
Op::run(array_get<n>(a), array_get<n>(b))...)) {
return reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A(), B()))>::type...>::run(
@@ -541,7 +538,7 @@ constexpr EIGEN_STRONG_INLINE auto h_array_zip_and_reduce(array<A, N> a, array<B
}
template <typename Reducer, typename Op, typename A, typename B, std::size_t N>
constexpr EIGEN_STRONG_INLINE auto array_zip_and_reduce(array<A, N> a, array<B, N> b)
constexpr auto array_zip_and_reduce(array<A, N> a, array<B, N> b)
-> decltype(h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type())) {
return h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type());
}
@@ -549,19 +546,19 @@ constexpr EIGEN_STRONG_INLINE auto array_zip_and_reduce(array<A, N> a, array<B,
/* apply stuff to an array */
template <typename Op, typename A, std::size_t N, int... n>
constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A())), N> h_array_apply(array<A, N> a, numeric_list<int, n...>) {
constexpr array<decltype(Op::run(A())), N> h_array_apply(array<A, N> a, numeric_list<int, n...>) {
return array<decltype(Op::run(A())), N>{{Op::run(array_get<n>(a))...}};
}
template <typename Op, typename A, std::size_t N>
constexpr EIGEN_STRONG_INLINE array<decltype(Op::run(A())), N> array_apply(array<A, N> a) {
constexpr array<decltype(Op::run(A())), N> array_apply(array<A, N> a) {
return h_array_apply<Op>(a, typename gen_numeric_list<int, N>::type());
}
/* apply stuff to an array and reduce */
template <typename Reducer, typename Op, typename A, std::size_t N, int... n>
constexpr EIGEN_STRONG_INLINE auto h_array_apply_and_reduce(array<A, N> arr, numeric_list<int, n...>)
constexpr auto h_array_apply_and_reduce(array<A, N> arr, numeric_list<int, n...>)
-> decltype(reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A()))>::type...>::run(
Op::run(array_get<n>(arr))...)) {
return reduce<Reducer, typename id_numeric<int, n, decltype(Op::run(A()))>::type...>::run(
@@ -569,7 +566,7 @@ constexpr EIGEN_STRONG_INLINE auto h_array_apply_and_reduce(array<A, N> arr, num
}
template <typename Reducer, typename Op, typename A, std::size_t N>
constexpr EIGEN_STRONG_INLINE auto array_apply_and_reduce(array<A, N> a)
constexpr auto array_apply_and_reduce(array<A, N> a)
-> decltype(h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type())) {
return h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type());
}
@@ -582,7 +579,7 @@ constexpr EIGEN_STRONG_INLINE auto array_apply_and_reduce(array<A, N> a)
template <int n>
struct h_repeat {
template <typename t, int... ii>
constexpr static EIGEN_STRONG_INLINE array<t, n> run(t v, numeric_list<int, ii...>) {
constexpr static array<t, n> run(t v, numeric_list<int, ii...>) {
return {{typename id_numeric<int, ii, t>::type(v)...}};
}
};

View File

@@ -156,8 +156,8 @@ class variable_if_dynamic {
EIGEN_ONLY_USED_FOR_DEBUG(v);
eigen_assert(v == 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 static constexpr T value() { return T(Value); }
EIGEN_DEVICE_FUNC 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));
@@ -184,7 +184,7 @@ class variable_if_dynamicindex {
EIGEN_ONLY_USED_FOR_DEBUG(v);
eigen_assert(v == T(Value));
}
EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE constexpr T value() { return T(Value); }
EIGEN_DEVICE_FUNC static constexpr T value() { return T(Value); }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T) {}
};