diff --git a/wpimath/src/main/native/include/frc/geometry/Rotation2d.h b/wpimath/src/main/native/include/frc/geometry/Rotation2d.h index 8f89556dd8d..6e9cd8e2a88 100644 --- a/wpimath/src/main/native/include/frc/geometry/Rotation2d.h +++ b/wpimath/src/main/native/include/frc/geometry/Rotation2d.h @@ -28,18 +28,11 @@ class WPILIB_DLLEXPORT Rotation2d { constexpr Rotation2d() = default; /** - * Constructs a Rotation2d with the given radian value. + * Constructs a Rotation2d with the given angle. * - * @param value The value of the angle in radians. + * @param value The value of the angle. */ - constexpr Rotation2d(units::radian_t value); // NOLINT - - /** - * Constructs a Rotation2d with the given degree value. - * - * @param value The value of the angle in degrees. - */ - constexpr Rotation2d(units::degree_t value); // NOLINT + constexpr Rotation2d(units::angle_unit auto value); // NOLINT /** * Constructs a Rotation2d with the given x and y (cosine and sine) diff --git a/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc b/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc index 0d9e97d4977..a222b362317 100644 --- a/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc +++ b/wpimath/src/main/native/include/frc/geometry/Rotation2d.inc @@ -11,13 +11,10 @@ namespace frc { -constexpr Rotation2d::Rotation2d(units::radian_t value) +constexpr Rotation2d::Rotation2d(units::angle_unit auto value) : m_value(value), - m_cos(gcem::cos(value.to())), - m_sin(gcem::sin(value.to())) {} - -constexpr Rotation2d::Rotation2d(units::degree_t value) - : Rotation2d(units::radian_t{value}) {} + m_cos(gcem::cos(value.template convert().value())), + m_sin(gcem::sin(value.template convert().value())) {} constexpr Rotation2d::Rotation2d(double x, double y) { double magnitude = gcem::hypot(x, y); diff --git a/wpimath/src/main/native/include/units/base.h b/wpimath/src/main/native/include/units/base.h index 34cd59e4198..bbb8a2bc4f0 100644 --- a/wpimath/src/main/native/include/units/base.h +++ b/wpimath/src/main/native/include/units/base.h @@ -53,7 +53,6 @@ #if !defined(_MSC_VER) || _MSC_VER > 1800 # define UNIT_HAS_LITERAL_SUPPORT -# define UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT #endif #ifndef UNIT_LIB_DEFAULT_TYPE @@ -358,25 +357,14 @@ template<> inline constexpr const char* abbreviation(const namespaceName::nameSi /** @endcond */\ } -#if defined(UNIT_HAS_VARIADIC_TEMPLATE_SUPPORT) #define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)\ namespace traits\ {\ template struct is_ ## unitCategory ## _unit : std::integral_constant>::value...>::value> {};\ template inline constexpr bool is_ ## unitCategory ## _unit_v = is_ ## unitCategory ## _unit::value;\ - } -#else -#define UNIT_ADD_IS_UNIT_CATEGORY_TRAIT(unitCategory)\ - namespace traits\ - {\ - template\ - struct is_ ## unitCategory ## _unit : std::integral_constant::type>::value &&\ - units::traits::detail::is_ ## unitCategory ## _unit_impl::type>::value &&\ - units::traits::detail::is_ ## unitCategory ## _unit_impl::type>::value>{};\ - template\ - inline constexpr bool is_ ## unitCategory ## _unit_v = is_ ## unitCategory ## _unit::value;\ - } -#endif + }\ + template \ + concept unitCategory ## _unit = traits::is_ ## unitCategory ## _unit_v; #define UNIT_ADD_CATEGORY_TRAIT(unitCategory)\ UNIT_ADD_CATEGORY_TRAIT_DETAIL(unitCategory)\