
3 May
2010
3 May
'10
11:50 p.m.
using boost::units; typedef make_scaled_unit<si::pressure, scale<10, static_rational< 9>
::type gpa_unit; gpa_unit GPa; quantity<gpa_unit> p(1.*GPa); //or p(1.*si::giga*si::pascal);
the question is, is there a simpler way of doing this? for example,
While it is not (yet) standards compliant, most current C++ compilers support this, which is about as easy as you can get : #include <boost/units/systems/si.hpp> #include <boost/units/systems/si/prefixes.hpp> using namespace boost::units; typedef typeof(si::giga*si::pascals) gigapascal_type; int main() { std::cout << 1.5*gigapascal_type() << std::endl; return 0; } Matthias