-
Notifications
You must be signed in to change notification settings - Fork 285
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
Extend createShapeNode to accept more types of arguments #986
Conversation
@mxgrey Could you take a look at this when you have a chance? |
First, notice that if you change line 43 to:
then it builds just fine. Essentially, what's happening is the C++ overload inference rules are working against us in this scenario. Before the compiler attempts to implicitly upcast the This kind of issue would be solved by C++ "Concepts", but unfortunately that won't be available until C++20 at the earliest. I'm creating a fix for this right now. It simply involves creating an overload of the template that's specialized for I'm in the process of testing the fix right now. Would you like me to push it to this branch when it's finished? |
Thanks for the explanation. Yeah, I remember I had the same issue with template function before. C++ is always more complex then I expected. 😱
Sure, feel free to push to this branch. |
I've pushed the fix, as well as some additional tests. |
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.
Thanks for the quick fix! I left a question below.
dart/dynamics/detail/BodyNode.hpp
Outdated
template <class ShapeType> | ||
ShapeNode* BodyNode::createShapeNode(const std::shared_ptr<ShapeType>& shape) | ||
{ | ||
return createShapeNode(static_cast<ShapePtr>(shape)); |
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.
Could we remove the non-template function by having the implementation here? I think this template function can handle the case as well. 🤔 If this works, we could apply this to the below function as well.
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.
Good point. I'll try that out right now and then push it if it works (which I fully expect it will).
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.
The change worked, so I've pushed it.
The one caveat with this is it breaks ABI compatibility, so anyone who was using that function will need to recompile. We don't support ABI compatibility between minor versions, so this doesn't violate our guidelines, but it's something to watch out for.
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.
On the bright side, we've reduced three functions to two while also expanding their usability.
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.
Yeah, I like this change. Btw, I recall that the same issue was of createShapeNode(shape, name)
. I couldn't pass const char*
for the name because of the template function. Now everything is resolved in a neat way!
@mxgrey This PR looks good to go. Feel free to update changelog (and the PR title) and merge. |
Codecov Report
@@ Coverage Diff @@
## release-6.4 #986 +/- ##
==============================================
+ Coverage 56.67% 56.7% +0.02%
==============================================
Files 310 310
Lines 23960 23958 -2
==============================================
+ Hits 13580 13585 +5
+ Misses 10380 10373 -7
|
Are we concerned about the alleged Travis failures? It seems to be complaining about failing to install |
Let's ignore build tests on macOS. I genuinely don't know how to resolve it. 😞 |
GCC 7.2.0/Clang Apple LLVM 9.0.0 fail to build
createShapeNode()
with errors as follows:Travis also reports the same error.