Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10270: square root of boost units scaled_unit fails to compile
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-31 00:53:20
#10270: square root of boost units scaled_unit fails to compile
-------------------------------+-----------------------------
Reporter: sharifmarat@⦠| Owner: matthiasschabel
Type: Bugs | Status: new
Milestone: To Be Determined | Component: units
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: scale
-------------------------------+-----------------------------
Comment (by Wouter Boomsma <wb@â¦>):
I'm stuck with the same problem. Is there any hope for a fix in the near
future? It would really be greatly appreciated.
As far as I can see, the suggested work-around does not work in my case,
since the scaled unit is not a base unit. In my application, I need a
kilojoule unit. The obvious approach would be:
typedef make_scaled_unit<si::energy, scale<10, static_rational<3> >
>::type energy_unit_kJ;
However, if this unit is involved in any nontrivial calculations involving
sqrt or pow, it fails as described above.
The scaled_base_unit workaround suggested by bnorman does not work
directly since joule is not a base unit. Instead, I attempted to define a
base unit from scratch, and set up the conversion factory manually:
struct energy_base_unit_kJ: base_unit<energy_base_unit_kJ,
energy_dimension, 1> {
static std::string name() {return "kilojoule";}
static std::string symbol() { return "kJ"; }
};
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(
energy_base_unit_kJ,
si::energy,
double, 1/1000.0);
The problem is that I cannot define the reverse conversion factor because
si::energy is not a base unit, and BOOST_UNITS_DEFINE_CONVERSION_FACTOR
requires its first argument to be a base unit.
If there is some clever way to work around this, I would appreciate a
pointer in the right direction - but under all circumstances, it would
really be convenient if make_scaled_unit just worked.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10270#comment:3> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC