|
Boost Users : |
Subject: [Boost-users] [units] unit conversion on construction in relation to argument passing
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-03-25 01:04:08
Hi,
Boost.Units offers automatic conversion (if conversion factor is
defined) on construction of variables:
quantity<cgs::lengh> A = 4.*cgs::centimeter;
quantity<si::length> a(A);
nice! But for some reason I believe this would work for argument
functions
double f(quantity<si::length> v){ return 1.;}
...
quantity<cgs::lengh> A = 4.*cgs::centimeter
f(A); // doesn't work! not matching function
why is this? isn't the argument of the call a sort of construction
argument for the function argument, or is more like a plain
assignment. Is there a way to force the automatic conversion of the
function call.
Or I am forced to use this other long call?
f(quantity<si::length>(A));
Thanks
Alfredo
Full code:
#include<boost/units/systems/si.hpp>
#include<boost/units/systems/cgs.hpp>
double f(quantity<si::length> v){ return 1.; }
int main(){
quantity<cgs::length> A(4.*cgs::centimeter);
f(A); //not matching function
return 0;
}
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