Closed djava closed 1 year ago
/azp run
Done
@djava We don't think this can get merged due to breaking changes in the constructors. The constructors that take vectors have been changed to take references to vectors, and the constructor that takes an initializer list of motors is now non-explicit.
These changes are good fine PROS 4, but we cannot accept these into PROS 3 since they break the ABI. This will break any templates that are not compiled against newer kernels.
I will revert that one to passing by value
I will revert that one to passing by value
Thank you. We will make them references in PROS 4 though.
That was a lot of commits to do that 🥴 oops
Looks good! I'm still trying to figure out if the explicit
keyword breaks ABI or not.
I will try to apply this kernel to an out of date template to ensure that these changes aren't ABI breaking.
Looks good! I'm still trying to figure out if the
explicit
keyword breaks ABI or not.
I'm not certain but I find it hard to imagine that it would
Yeah, I don't imagine it would, but we didn't think that switching the motor's constructors to signed would break much, but it did. I would just rather be safe than sorry so that we don't repeat that mistake.
Summary:
Motor_Group::Motor_Group(const std::vector<pros::Motor>& motors)
b.Motor_Group::Motor_Group(const std::initializer_list<std::int8_t> motor_ports)
explicit
tag from theMotor_Group(const std::initializer_list<Motor>)
ctorMotor_Group(const std::vector<std::int8_t>)
ctor toMotor_Group(const std::vector<std::int8_t>&)
(passes by const-ref instead of by value)Motor_Group(const std::vector<std::int8_t>&)
to use a range-basedfor
loop andstd::vector::emplace_back
instead ofstd::vector::push_back
Motivation:
std::vector<Motor>&
removes the restriction thatMotor_Group
s could only be constructed with literal brace-enclosed lists ofMotor
s that existed becausestd::initializer_list
is designed to exist only as an rvalue. Now the options for constructing aMotor_Group
withMotor
s are far more flexible. b. Allows for a more efficient construction ofMotor_Groups
using a literal brace-enclosed list of port numbers than only acceptingstd::vector<uint8_t>
for portsMotor
shouldn't be implicitly convertible toMotor_Group
. This change seems like it could create more ergonomic function calls in places, without any real downsides.emplace_back(port)
constructs theMotor
s in-place inside the vector instead of creating temporaryMotor
s and copying them into the vector, aspush_back(Motor(port))
does. Also uses range-basedfor
loop to be more idiomatic.References (optional):
Original inspiration for 1: https://discord.com/channels/197777408198180864/198658294007463936/1044109726675390544
Test Plan:
Motor_Group
s work as expected. I don't foresee any issues with functionality as long as it compiles.