Boost logo

Boost Users :

Subject: Re: [Boost-users] boost/units - converting forces (lbf->N)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-12-01 17:35:08


AMDG

On 12/01/2018 06:25 AM, Matt Vinson via Boost-users wrote:
> To see if I understand the library, I want to create metric and imperial systems without using Boost Units predefined systems*.  Conversions between lengths are going well.  Conversion between forces are going well until pounds-force to newtons; line 182 in the link.  What am I doing wrong when lbf will not convert to newtons?
>

There are a few problems.

- BOOST_UNITS_DEFAULT_CONVERSION takes a unit (not a
  base unit) as its second argument.
- You are defining both a kilogram_base_unit and a kilo_gram_base_unit.
  Either one will work, but you need to be consistent. You're
  defining the conversion in terms of kilo_gram_base_unit, but
  metric::system uses kilogram_base_unit.
- The definition of a composite conversion for force is not
  needed and will be ignored.
- metric and imperial have separate definitions of second_base_unit
  with no conversion between them.
- lbf is not the same as (lbm in s^-2)

> Here is my code:
> https://coliru.stacked-crooked.com/a/f5f80d39fbdf8013
> Any help is appreciated.
>
> *
> //imperial
> namespace boost {namespace units {
> namespace us {}}}//sinamespace boost {
> namespace units {
> namespace si {}}}
>

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