Skip to content

Commit

Permalink
Fix an issue where forced inlining conflicted with constexpr on gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jun 16, 2024
1 parent f2928d4 commit 7f9697c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/symtensor/SymmetricTensorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ namespace symtensor {
ALWAYS_INLINE static constexpr Implementation NullaryExpression(F function = {}) {
if constexpr (requires { function.template operator()<dimensionalIndices(0)>(); }) {
// If a function provides a template parameter for compile-time indexing, prefer that
return [&]<std::size_t... i>(std::index_sequence<i...>) LAMBDA_ALWAYS_INLINE constexpr {
return [&]<std::size_t... i>(std::index_sequence<i...>) LAMBDA_ALWAYS_INLINE {
return Implementation{static_cast<S>(function.template operator()<dimensionalIndices(i)>())...};
}(std::make_index_sequence<NumUniqueValues>());
} else {
// Otherwise, the function must take the indices as its only argument
return [&]<std::size_t... i>(std::index_sequence<i...>) LAMBDA_ALWAYS_INLINE constexpr {
return [&]<std::size_t... i>(std::index_sequence<i...>) LAMBDA_ALWAYS_INLINE {
return Implementation{static_cast<S>(function(dimensionalIndices(i)))...};
}(std::make_index_sequence<NumUniqueValues>());
}
Expand Down
3 changes: 1 addition & 2 deletions include/symtensor/gravity.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ namespace symtensor::gravity {

template<std::size_t N, indexable Vector>
ALWAYS_INLINE auto derivative(const Vector &R) {
return SymmetricTensor3f<N>::NullaryExpression([&]<auto index>() LAMBDA_ALWAYS_INLINE constexpr {
return SymmetricTensor3f<N>::NullaryExpression([&]<auto index>() LAMBDA_ALWAYS_INLINE {
return derivative_at<index, N>(R);
});

};


Expand Down

0 comments on commit 7f9697c

Please sign in to comment.