Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] Runtime dimension check
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-09-01 10:28:58


AMDG

Thomas Taylor wrote:
> Is there an easy way to check if two quantities have the same dimension?
>
> E. g. a user enters a weight in tons and asks for a conversion to kilograms.
> So now at run time I would like to know if tons and kilograms have the same
> dimensions (i. e. are convertable) or not (illegal conversion).
>

Each unit has a nested dimension_type typedef. Use it with boost::is_same.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net