
Hello Steven, thanks for your great work on Units! On Mon, May 8, 2017 at 3:11 PM, Steven Watanabe via Boost-users < boost-users@lists.boost.org> wrote:
The meaning is literally division. (1.0 * meters) / meters = 1.0 If the expression exactly cancels out all units, then the result is dimensionless and can be implicitly converted to a double.
OK, I see. From my perspective, having never used Units this was not quite intuitive if you don't mind me say so. If you would allow me to get a little off topic.... My reason behind switching to units was that I wanted to get rid of implicit assumptions about what unit a quantity is in. I am in a client / server environment and store such vectors coming from a client that uses centimeters as all units. Now I expect further clients and want to be prepared for them to use other units, say millimeters. By using Units I intend to push that translation to the foremost interface of the system and not translate anything behind that. I have much appreciated the constructor of quantity and the fact that it fails to compile without a unit to give meaning to a scalar. This is an excellent design paradigm and will help eliminate bugs! qlength q(42.0 * meters); Nice. My problem that led to the above misconception was, that I needed to translate that back and forth to the client. From the client was quite easy: qlength q(4200.0 * centi*meters); Looks good enough. But getting the value back in centimeters was not. I tried: double raw_value_to_send_back = q / centi*meters; But this won't compile. So I looked into scaled units and typedefed this: typedef boost::units::make_scaled_unit< boost::units::si::length, boost::units::scale<10, boost::units::static_rational<-2> > >::type centimeters; And now I can convert into centimers like this: double raw_value_to_send_back = quantity<centimeters, double>(n_value).value(); But still, I'm not sure I am using it as intended. Is this the best and easiest way to handle such things or am I mistaken and q / centi*meters really is supposed to work? Best regards... Stephan