-
Notifications
You must be signed in to change notification settings - Fork 137
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
Support integral underlying types #126
Conversation
479fb3d
to
8afd403
Compare
looking awesome so far. |
54ee4bc
to
75eb9ef
Compare
75eb9ef introduces You'll see the addition of a few macros. The flattening allowed me to discover a few units that before were equivalent, e.g. I'll add the documentation later. |
dd0ea2e
to
e490fc9
Compare
The I couldn't come up with a change that provides the benefits of both. And it wasn't even necessary to do so. I thought it'd be nice to use |
35a7c01
to
4320117
Compare
I've been hacking up changes to v2.3 to make it easier to mix units with underlying types (my use-case is outlined at the end of this issue), and I see some overlap with this work. For example, this would let you add a float-based meter type to a double-based meter type. Should we coordinate? |
Sure! We could do it here or in my fork. |
I have reread your message (I had done so before, back when I was contemplating someday using this library). The changes I'm going to do will indeed allow you to do 1 and 2, but 3 is not part of this effort. What does the library do that impedes its Regarding your remark about |
4320117
to
69ad94d
Compare
I had been struggling with formulating a specialization of |
9d858c0
to
5a5ef15
Compare
I think that does it. Now I can continue with the tasks. Any bug with the specialization of |
1f1f324
to
23685b9
Compare
include/units.h
Outdated
units::unit< | ||
units::unit_conversion< | ||
units::detail::ratio_gcd<typename UnitConversionLhs::conversion_ratio, typename UnitConversionRhs::conversion_ratio>, | ||
typename UnitConversionLhs::dimension_type, |
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 wonder if using dimension_of_t
would be most correct here.
ba3aa75
to
c826471
Compare
I think it's done. If anything, I should add some tests for the last five items in the lists ("Use the new framework in"), which only used the existing tests, which don't account for mixed-underlying types units. Now unused: Further work:
|
83f047f
to
bc20884
Compare
It can be refactored further. From |
4c6a0ee
to
992c28d
Compare
aa7d66d
to
47f42e4
Compare
47f42e4
to
8cacbae
Compare
This macro is part of the public API. As such, the definitions are in terms of the strong unit alias. If an object of it degenerates into its base, something else might be printed. In practice, this might not be a problem. If the unit is a program-defined unit, the base might print the right thing. If it is a strong unit alias over a library-defined unit, something different, but correct nonetheless, might be printed. See nholthaus#126 (comment).
This macro is part of the public API. As such, the definitions are in terms of the strong unit alias. If an object of it degenerates into its base, something else might be printed. In practice, this might not be a problem. If the unit is a program-defined unit, the base might print the right thing. If it is a strong unit alias over a library-defined unit, something different, but correct nonetheless, might be printed. See nholthaus#126 (comment).
This macro is part of the public API. As such, the definitions are in terms of the strong unit alias. If an object of it degenerates into its base, something else might be printed. In practice, this might not be a problem. If the unit is a program-defined unit, the base might print the right thing. If it is a strong unit alias over a library-defined unit, something different, but correct nonetheless, might be printed. See nholthaus#126 (comment).
This macro is part of the public API. As such, the definitions are in terms of the strong unit alias. If an object of it degenerates into its base, something else might be printed. In practice, this might not be a problem. If the unit is a program-defined unit, the base might print the right thing. If it is a strong unit alias over a library-defined unit, something different, but correct nonetheless, might be printed. See nholthaus#126 (comment).
This macro is part of the public API. As such, the definitions are in terms of the strong unit alias. If an object of it degenerates into its base, something else might be printed. In practice, this might not be a problem. If the unit is a program-defined unit, the base might print the right thing. If it is a strong unit alias over a library-defined unit, something different, but correct nonetheless, might be printed. See nholthaus#126 (comment).
Resolves #125.
convert
that carries intermediate computations in the widest representation and has a type safe interface.std::common_type
for units of the same dimension. The common type should be the least precise unit that both units can be exactly converted to.Along the way, some of the supporting traits and other utilities might need to be changed to support mixed underlying types.