You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
AMDG
`one` was never intended to be a public API. It exists
to simplify several parts of the implementation and was
only designed to work with scalars.
In Christ,
Steven Watanabe
While working on an adaptation of a generic vector class to support
boost::units
, I foundboost::units::one
to be quite helpful. It can act as a substitute for aunit_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, orone
, divided by actual values. This bringsdivide_typeof_helper<one, T>::type
into play. Which turns out to beT
, even ifT
is a unit or a quantity type. (Such specializations are given indetail/one.hpp
andquantity.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>
(sincestatic_int_power_sign_impl<N, true>
literally usesdivide_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 constantx
, you can use the attached boost-units-one-div.cc.txt as a basis for a test case.The text was updated successfully, but these errors were encountered: