Make feedforward classes constexpr (#2103)

ArmFeedforward::Calculate() can't be made constexpr because std::cos()
and thus units::math::cos() is not constexpr.

Fixes #2101.
This commit is contained in:
Tyler Veness
2019-11-19 06:47:59 -08:00
committed by Peter Johnson
parent 500c43fb84
commit 845aba33fe
5 changed files with 27 additions and 53 deletions

View File

@@ -838,9 +838,10 @@ SaturatingMultiplyAdd(T X, T Y, T A, bool *ResultOverflowed = nullptr) {
return SaturatingAdd(A, Product, &Overflowed);
}
// Typesafe implementation of the signum function. Returns -1 if negative, 1 if positive, 0 if 0.
// Typesafe implementation of the signum function.
// Returns -1 if negative, 1 if positive, 0 if 0.
template <typename T>
int sgn(T val) {
constexpr int sgn(T val) {
return (T(0) < val) - (val < T(0));
}