-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adds safe signed->unsigned, unsigned->signed casts #188
Conversation
Looks nice. What is the use case you have in mind? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #188 +/- ##
===========================================
+ Coverage 64.64% 64.69% +0.04%
===========================================
Files 1105 1107 +2
Lines 55988 56064 +76
Branches 4234 4235 +1
===========================================
+ Hits 36193 36269 +76
Misses 19795 19795 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Private downstream CI failed. |
Private downstream CI failed. |
I am reading a signed value in Hermes (which should have been a unsigned value), and since I am receiving the value form the network I want to ensure the service is safely converting the value, or raise an error that can be handled gracefully. |
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 will be very useful!
Note, the unit test fails compilation for rocky-8.6.
Sometimes wrapping the argument in parentheses could work around in my experience. Worth a try: EXPECT_EQUAL(into_unsigned(int8_t{5}), (uint8_t{5})); |
i like this PR :-) But I would like to raise the discussion, shouldn't this be integrated with eckit::Translator ? It serves a similar purpose, and we'de benefit from integrating this PR's more-natural interface into the more cumbersome Translator operator()(...) |
I haven't even looked into translator... (or was particularly aware of its existence) Let me have a look and i'll get back to you. |
Note that we have already added the translate() function which somewhat improves the Translator functionality. |
Ok so I had some time to look into the translator. I think this should not become part of the translator. All specializations in Translator.h deal with serialization or deserialization (one of FROM/TO are |
Private downstream CI succeeded. |
1 similar comment
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Can we move on with this as it is now or do you have specific change requests? |
Yes, please merge this with Translator (in the right place) -- otherwise we will start having multiple ways of doing the same thing |
My guess is miscommunication. I suspect @pmaciel didn't mean to replace this functionality with eckit::Translator and he doesn't mean that you should be using eckit::Translator. Rather he means to refactor eckit::Translator to make use of this new functionality, if possible. |
Yes indeed - to me the SafeCasts file is fine, it's just Translator should use this for its existing (and possibly missing) specialisations |
+1 thank ms for the clarification! Will do! |
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.
After a call with @Ozaq we agreed to make a more modern solution, while providing a easy transition.
4bdfd93
to
808aa73
Compare
Private downstream CI succeeded. |
1 similar comment
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI failed. |
Adds new 'into_unsigned()' and 'into_signed' type casts that throw on conversion from a unrepresentable value in the target representation.
Private downstream CI succeeded. |
2 similar comments
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI succeeded. |
2 similar comments
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Private downstream CI succeeded. |
2 similar comments
Private downstream CI succeeded. |
Private downstream CI succeeded. |
Adds new 'into_unsigned()' and 'into_signed' type casts that throw on conversion from a unrepresentable value in the target representation.