Skip to content
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

one/quantity support #39

Open
ccorn opened this issue Aug 6, 2019 · 2 comments
Open

one/quantity support #39

ccorn opened this issue Aug 6, 2019 · 2 comments

Comments

@ccorn
Copy link

ccorn commented Aug 6, 2019

While working on an adaptation of a generic vector class to support boost::units, I found boost::units::one to be quite helpful. It can act as a substitute for a unit_type when there is no quantity (and no system of units) involved, e.g. just a built-in floating-point type.

Using one got me quite far until I tried to prepare for instances of units, or one, divided by actual values. This brings divide_typeof_helper<one, T>::type into play. Which turns out to be T, even if T is a unit or a quantity type. (Such specializations are given in detail/one.hpp and quantity.hpp.) The expected result would be something with the reciprocated unit type, i.e. all base unit exponents sign-flipped.

I have looked for effects on officially documented functions, including pow<-1> (since static_int_power_sign_impl<N, true> literally uses divide_typeof_helper<one,), but I have found no misbehavior on the surface. Somehow the implementation manages to avoid this case, so I cannot label this as a bug.

Nevertheless, if you want boost::units::one() / x to work as intended for a quantity or unit constant x, you can use the attached boost-units-one-div.cc.txt as a basis for a test case.

@swatanabe
Copy link
Contributor

swatanabe commented Aug 6, 2019 via email

@correaa
Copy link

correaa commented Aug 7, 2019

@ccorn, I personally define a constant called "uno" (symbol "U") https://iopscience.iop.org/article/10.1088/0026-1394/35/6/3
Would that work for you?

https://gitlab.com/correaa/boost-units/blob/master/systems/si/abbreviations.hpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants