Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Dimensionless? expecting length+length
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-08-10 22:06:43

On 11/08/2015 01:43, Michael Powell wrote:
>> Try normalising the milliseconds to seconds before putting them in the rest
>> of the formula. You should be able to do this simply by assigning them to a
>> seconds quantity type instead of using "auto".
> I'm not sure what you mean, "seconds quantity type"?
> There would be quantity<time> ?

Yes. I have this:

typedef quantity<time> Time;

And explicitly use "Time" as the type for all time-related results
instead of using "auto".

> Which one can assign from (time_value * seconds), to arrive at seconds?
> It is possible to build up a milliseconds unit, or possible a
> milliseconds_to_seconds "conversion factor" ?

You can, but it's not necessary. Simply assign value * milli * seconds
to a variable of quantity<time> (aka Time) and it automatically converts
everything to seconds (since that's the base unit of "time"). This
prevents other operations getting confused by scaled units, which
happens when you use "auto" because it skips this conversion.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at