Opened 10 years ago

#6957 new Bugs

Boost.units: static pow<>() fails for quantities with non-double type

Reported by: Anna Jaruga <ajaruga@…> Owned by: Matthias Schabel
Milestone: To Be Determined Component: units
Version: Boost 1.48.0 Severity: Problem
Keywords: units pow Cc:

Description

Below is a short example depicting that pow<>() works only in the quantity in the argument has double precision representation. Hope that helps.

ajaruga@granda:~/icicle$ cat test.cpp #include <boost/units/pow.hpp> #include <boost/units/systems/si.hpp> using namespace boost::units;

int main() {

quantity<si::length, real_t> a = 1 * si::metres; quantity<si::volume, real_t> b = pow<3>(a);

} ajaruga@granda:~/icicle$ g++ -Dreal_t=double test.cpp && echo OK OK ajaruga@granda:~/icicle$ g++ -Dreal_t=float test.cpp && echo OK test.cpp: In function ‘int main()’: test.cpp:7:44: error: conversion from ‘boost::units::power_typeof_helper<boost::units::quantity<boost::units::unit<boost::units::list<boost::units::dim<boost::units::length_base_dimension, boost::units::static_rational<1l> >, boost::units::dimensionless_type>, boost::units::homogeneous_system<boost::units::list<boost::units::si::meter_base_unit, boost::units::list<boost::units::scaled_base_unit<boost::units::cgs::gram_base_unit, boost::units::scale<10l, boost::units::static_rational<3l> > >, boost::units::list<boost::units::si::second_base_unit, boost::units::list<boost::units::si::ampere_base_unit, boost::units::list<boost::units::si::kelvin_base_unit, boost::units::list<boost::units::si::mole_base_unit, boost::units::list<boost::units::si::candela_base_unit, boost::units::list<boost::units::angle::radian_base_unit, boost::units::list<boost::units::angle::steradian_base_unit, boost::units::dimensionless_type> > > > > > > > > > >, float>, boost::units::static_rational<3l> >::type {aka boost::units::quantity<boost::units::unit<boost::units::list<boost::units::dim<boost::units::length_base_dimension, boost::units::static_rational<3l> >, boost::units::dimensionless_type>, boost::units::homogeneous_system<boost::units::list<boost::units::si::meter_base_unit, boost::units::list<boost::units::scaled_base_unit<boost::units::cgs::gram_base_unit, boost::units::scale<10l, boost::units::static_rational<3l> > >, boost::units::list<boost::units::si::second_base_unit, boost::units::list<boost::units::si::ampere_base_unit, boost::units::list<boost::units::si::kelvin_base_unit, boost::units::list<boost::units::si::mole_base_unit, boost::units::list<boost::units::si::candela_base_unit, boost::units::list<boost::units::angle::radian_base_unit, boost::units::list<boost::units::angle::steradian_base_unit, boost::units::dimensionless_type> > > > > > > > > > >, double>}’ to non-scalar type ‘boost::units::quantity<boost::units::unit<boost::units::list<boost::units::dim<boost::units::length_base_dimension, boost::units::static_rational<3l> >, boost::units::dimensionless_type>, boost::units::homogeneous_system<boost::units::list<boost::units::si::meter_base_unit, boost::units::list<boost::units::scaled_base_unit<boost::units::cgs::gram_base_unit, boost::units::scale<10l, boost::units::static_rational<3l> > >, boost::units::list<boost::units::si::second_base_unit, boost::units::list<boost::units::si::ampere_base_unit, boost::units::list<boost::units::si::kelvin_base_unit, boost::units::list<boost::units::si::mole_base_unit, boost::units::list<boost::units::si::candela_base_unit, boost::units::list<boost::units::angle::radian_base_unit, boost::units::list<boost::units::angle::steradian_base_unit, boost::units::dimensionless_type> > > > > > > > > > >, float>’ requested

Change History (0)

Note: See TracTickets for help on using tickets.