mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpimath, wpiutil] Add wpi::array for compile time size checking (#3087)
The wpimath APIs use std::array, which doesn't do size checking. Passing an array with the wrong size can result in uninitialized elements instead of a compilation error. This is a breaking change but is worthwhile to avoid hard-to-debug errors.
This commit is contained in:
@@ -31,7 +31,7 @@ class SwerveControllerCommandTest : public ::testing::Test {
|
||||
frc2::Timer m_timer;
|
||||
frc::Rotation2d m_angle{0_rad};
|
||||
|
||||
std::array<frc::SwerveModuleState, 4> m_moduleStates{
|
||||
wpi::array<frc::SwerveModuleState, 4> m_moduleStates{
|
||||
frc::SwerveModuleState{}, frc::SwerveModuleState{},
|
||||
frc::SwerveModuleState{}, frc::SwerveModuleState{}};
|
||||
|
||||
@@ -60,7 +60,7 @@ class SwerveControllerCommandTest : public ::testing::Test {
|
||||
|
||||
void TearDown() override { frc::sim::ResumeTiming(); }
|
||||
|
||||
std::array<frc::SwerveModuleState, 4> getCurrentWheelSpeeds() {
|
||||
wpi::array<frc::SwerveModuleState, 4> getCurrentWheelSpeeds() {
|
||||
return m_moduleStates;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user