Hello,
I'm trying to use absolute temperature in some expressions.
Unfortunately I'm having some issues with the compilation.
For instance, if I divide an absolute temperature by itself I would expect
to get 1 dimensionless, however that will cause a compilation error.
#include <iostream>
#include
#include
#include
#include
#include
int main(int argc, char** argv) {
using namespace boost::units;
quantitysi::temperature rT(273.15 * si::kelvin); // relative
temperature
quantitysi::dimensionless v;
v = rT / rT;
std::cout << v << std::endl; // 1 dimensionless
quantitysi::temperature > aT(273.15 *
absolutesi::temperature()); // absolute temperature
//v = aT / aT; // uncommenting this line will cause compilation errors
//std::cout << v << std::endl; // 1 dimensionless
return 0;
}
If I uncomment the line with v = aT / aT, in ubuntu 15.10 with boost 1.58
and gcc 5.2.1, I get the error:
(...)
/usr/include/boost/units/operators.hpp:81:5: error: no match for
‘operator/’ (operand types are
‘boost::units::absolute >, boost::units::dimensionless_type>,
boost::units::homogeneous_system > >,
boost::units::list > > > > > > > > > > >’ and
‘boost::units::absolute >, boost::units::dimensionless_type>,
boost::units::homogeneous_system > >,
boost::units::list > > > > > > > > > > >’)
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,
(typeof_::make<X>()/typeof_::make<Y>()))
(...)
I could add something like
namespace boost {
namespace units {
template
struct divide_typeof_helper,
quantity > {
typedef typename divide_typeof_helper::type value_type;
typedef typename divide_typeof_helper::type unit_type;
typedef quantity type;
};
}
}
but that would not work in more complex examples, e.g.:
#include
(...)
using namespace boost::units::si::constants::codata;
typedef boost::mpl::divides::type Ea_dimension;
typedef boost::units::unit Ea;
quantity<Ea> ea(0);
auto x = ea / (R * aT);
Any help would be most appreciated,
João Leal