[Boost-bugs] [Boost C++ Libraries] #10270: square root of boost units scaled_unit fails to compile

Subject: [Boost-bugs] [Boost C++ Libraries] #10270: square root of boost units scaled_unit fails to compile
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-29 08:39:49


#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
 Keywords: scale |
------------------------------+-----------------------------
 I have created a scaled unit to handle micro meters:
 {{{
 typedef make_scaled_unit<si::length,
                          scale<10, static_rational<-6> > >::type
 micro_meter_unit;
 }}}

 Everything works as expected:

 {{{
 quantity<si::length, double> some_meter = 10 * si::meter;
 quantity<micro_meter_unit, double> some_mu_meter =
   static_cast<quantity<micro_meter_unit, double>>(some_meter);

 std::cout << "some_meter^2 = " << some_meter * some_meter; // outputs 100
 m^2
 std::cout << "some_mu_meter^2 = " << some_mu_meter * some_mu_meter; //
 outputs 1e+014 p(m^2)
 }}}

 Yet the square root operations is not compiled:

 {{{
 std::cout << "sqrt(some_meter) = " << sqrt(some_meter); // outputs 3.16228
 m^(1/2)
 std::cout << "sqrt(some_mu_meter) = " << sqrt(some_mu_meter); //error here
 // 'value' : is not a member of 'boost::units::scale_dim_tag'
 }}}

 Also the following code fails to compile:

 {{{
 quantity<si::length, double> mu_meter(sqrt(1.0 * si::micro * si::meter *
 si::meter));
 }}}

 I used the following include files:

 {{{
 #include <iostream>
 #include <boost/units/quantity.hpp>
 #include <boost/units/make_scaled_unit.hpp>
 #include <boost/units/systems/si.hpp>
 #include <boost/units/cmath.hpp>
 #include <boost/units/io.hpp>
 #include <boost/units/scale.hpp>
 #include <boost/units/systems/si/prefixes.hpp>
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10270>
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:16 UTC