Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Units: Is it possible to convert on assignment without casting?
From: Robert Ramey (ramey_at_[hidden])
Date: 2019-01-14 15:59:34


On 1/14/19 12:50 AM, Carel Combrink via Boost-users wrote:
> Hi.

Stephane Watanabe can likely give a better answer. But I'm going to
take a shot anyhow. Note I made a presentation at CppCon 2015
https://www.youtube.com/watch?v=qphj8ZuZlPA&t=4s The slides and demo
code are available at
http://www.rrsd.com/software_development/boost/CPPCon2015/CPPCon2015.zip

>
> I have two unit quantities defined as follow:
> static const auto Hz  = boost::units::si::hertz;
> using Hertz     = boost::units::quantity<decltype( Hz ), double>;

On the wrong track here. Make a clearer distinction between quantities,
dimensions and and units. Also, I strongly recommend against using auto
in cases like this. It's by explicitly specifying the types which leads
one to understand where he has made an error in units/quantities/dimensions.

Robert Ramey


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