-
Notifications
You must be signed in to change notification settings - Fork 278
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
Added support for down_cast() and made changes in the codebase #1124
Conversation
@isuruf Ping. |
I think all we need is something like +template <typename To, typename From>
+inline To& down_cast(From &f)
+{
+ SYMENGINE_ASSERT(dynamic_cast<To*>(&f) != NULL);
+ return *static_cast<To*>(&f);
+} EDIT: Ignore above |
@certik, |
@isuruf why not? Does any compile produce a warning on that code? |
@ShikharJ I think so. I think that's also the only casting we do, don't we? |
@certik I am not really comfortable with |
Don't modify Teuchos. That library we just use as-is, and we assume it is correct. If it has bugs, then we'll report them upstream and they'll get fixed. We use Also do not modify the So I would suggest to only replace |
@certik Should I also make the changes when the argument is of a template type? Like the following case:
|
@ShikharJ I thinks so --- is there a reason not to? |
@certik The |
@ShikharJ I think |
Follow-up Corrections Follow-up Corrections(1) Preliminary Code Coverage Using down_cast()
@isuruf @certik |
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 looks very good. +1 to merge if tests pass. I left just a minor comment.
@@ -733,6 +733,7 @@ Teuchos::rcp_static_cast(const RCP<T1>& p1) | |||
#endif | |||
} | |||
|
|||
|
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.
Remove this line. The Teuchos library should not be modified.
{ | ||
// Only accept pointers. |
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.
Why this change?
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.
@isuruf I must've accidentally made the change. I'll correct it (anyways the build needs to be re-run as Travis had an issue with OSX related jobs previously).
@isuruf A final review? |
I think that this is good. Thanks @ShikharJ ! |
This is a follow up for PR #746 by Abhimanyu Siwach.
down_cast() has been used in place of static_cast() strictly in places where the arguments were of the type Basic or any of its derived classes.
Please suggest any changes if required.