mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpimath] Make various classes constexpr (#7237)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <numbers>
|
||||
#include <type_traits>
|
||||
|
||||
#include <gcem.hpp>
|
||||
#include <wpi/SymbolExports.h>
|
||||
|
||||
#include "units/angle.h"
|
||||
@@ -28,10 +29,10 @@ namespace frc {
|
||||
*/
|
||||
template <typename T>
|
||||
requires std::is_arithmetic_v<T> || units::traits::is_unit_t_v<T>
|
||||
T ApplyDeadband(T value, T deadband, T maxMagnitude = T{1.0}) {
|
||||
constexpr T ApplyDeadband(T value, T deadband, T maxMagnitude = T{1.0}) {
|
||||
T magnitude;
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
magnitude = std::abs(value);
|
||||
magnitude = gcem::abs(value);
|
||||
} else {
|
||||
magnitude = units::math::abs(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user