-
Notifications
You must be signed in to change notification settings - Fork 269
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
Use sdf FindElement API to avoid const_cast #2231
Conversation
Several systems use const_cast in order to call sdf::Element::GetElement with const ElementPtrs, but the FindElement API can be used instead. Signed-off-by: Steve Peters <[email protected]>
src/systems/diff_drive/DiffDrive.cc
Outdated
// Get params from SDF | ||
sdf::ElementPtr sdfElem = ptr->GetElement("left_joint"); | ||
sdf::ElementConstPtr sdfElem = _sdf->FindElement("left_joint"); |
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.
I think this is actually a good use case for auto
. We shouldn't really care what the type is and the compiler should enforce the const correctness.
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.
ok, I'll update this and similar types to auto
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.
I had a fever, and the prescription was more auto
Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #2231 +/- ##
==========================================
- Coverage 65.90% 65.88% -0.03%
==========================================
Files 323 323
Lines 30719 30713 -6
==========================================
- Hits 20245 20234 -11
- Misses 10474 10479 +5
|
looks good to me. Windows CI needs gazebosim/gz-common#550 |
@osrf-jenkins retest this please |
CI issues are unrelated, merging |
Several systems use const_cast in order to call sdf::Element::GetElement with const ElementPtrs, but the FindElement API can be used instead. Signed-off-by: Steve Peters <[email protected]>
Several systems use const_cast in order to call sdf::Element::GetElement with const ElementPtrs, but the FindElement API can be used instead. Signed-off-by: Steve Peters <[email protected]>
🦟 Bug fix
Fixes unneeded
const_cast
calls.Summary
Several systems use
const_cast
in order to callsdf::Element::GetElement
with constElementPtr
s, but theFindElement
API can be used instead.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.