$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [units] How to assign "ft" to an si::length?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-05-19 14:17:09
AMDG
Terry Golubiewski wrote:
> I am having trouble seeing how to use mixed units.
> The program below compiles and runs.
> See the changes I "wish" I could make as comments.
>
> terry
>
> #include <boost/units/systems/si.hpp>
> #include <boost/units/base_units/us/foot.hpp>
> #include <boost/units/quantity.hpp>
> #include <boost/units/io.hpp>
>
> #include <iostream>
> #include <iomanip>
>
> using namespace std;
> using namespace boost;
> using namespace boost::units;
>
> int main() {
>  static const si::length m = si::meter;
>  // static const si::length ft = ???;
>  typedef quantity<si::length> Length;
>  Length x = 2.0 * m;
>  Length y = 3.0 * m; // instead of "m" use "ft";
>  cout << "x=" << x << " y=" << y << endl;
>  Length z = x + y;
>  cout << "x+y=" << z << endl; // display result in "ft"
>  return 0;
> } // main
Warning: untested code
typedef quantty<us::foot_base_unit::unit_type> Length;
Length x(2.0 * m);
In Christ,
Steven Watanabe