-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function specifiers and modernize constructors #430
Add function specifiers and modernize constructors #430
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks very good to me, love to see code improvements with a negative balance sheet ;)
I am unsure about the virtual destructors though...
- A tiny bit unsure whether without declaring any, not even an override, derived class destructors will be virtual too
- Whether we should keep the virtual desctructor as a reminder for people using this class to define one. Yes this class gets it from it's parent but this class is meant to be subclassed from so I think we should not rely on implicit virtuals.
hardware_interface/include/hardware_interface/imu_sensor_interface.h
Outdated
Show resolved
Hide resolved
Yep, the derived class destructor will be virtual if there's a virtual destructor anywhere in the inheritance chain. As a quick sanity check: http://cpp.sh/4d4l
Hmm, I maybe see the argument for keeping it to make it extra clear that the class has a virtual destructor, but I don't think it's really important to tell that to the author of subclasses. They don't even need to be aware of the virtual dtor, since it doesn't affect how they write their code - If they need a destructor to do some cleanup for stuff in their class, they can add one, but if they don't need one, they don't need to add one. I think it's unnecessary to "remind people to define one" since not all subclasses will require a user-defined destructor, and they can just follow the regular rules about when to define one. I also think it's still pretty clear that |
It wasn't hard to convince me ;) Keeping |
Out of curiosity what's the criteria for For example, as far as I can tell, this one could be removed too. |
Which one is that link pointing to? The rationale was to remove as many as possible, and then only (I would also like all those ctor overloads to be |
hardware_interface/include/hardware_interface/force_torque_sensor_interface.h
Show resolved
Hide resolved
70231fe
to
162f9bd
Compare
Rebased for latest melodic, ready to merge once CI is happy |
Part of #403.
Add function specifiers (
override
,noexcept
) and cleanup ctors & dtors (= default
,= delete
, and removing unnecessary).A couple of notes:
virtual
specifiers were removed in favour ofoverride
s.throw()
->noexcept
. I did not add any additionalnoexcept
s though, only updated the existing ones in the custom exceptions.ImuSensorHandle::Data::Data()
must be user-defined, it cannot be= default
. See https://stackoverflow.com/a/17436088/1932358This was mostly done using
clang-tidy
: