Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] How to assign "ft" to an si::length?
From: Terry Golubiewski (tjgolubi_at_[hidden])
Date: 2010-05-19 16:43:52


----- Original Message -----
From: "Steven Watanabe" <watanabesj_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.user
To: <boost-users_at_[hidden]>
Sent: Wednesday, May 19, 2010 2:15 PM
Subject: Re: [units] How to assign "ft" to an si::length?

> AMDG
>
> Terry Golubiewski wrote:
>>> Warning: untested code
>>>
>>> typedef quantty<us::foot_base_unit::unit_type> Length;
>>> Length x(2.0 * m);
>>
>> Ok. That makes Length represent "feet"
>> But I want Length to remain represented as an si::length, but input
>> "ft" into it and convert to "ft" to print.
>>
>> // static const si::length ft = ???;
>> typedef quantity<si::length> Length;
>> Length x = 3.0 * ft;
>> cout << "x=" << convert_to_ft(x) << endl;
>
> typedef quantity<us::foot_base_unit::unit_type> convert_to_ft;

Got it! Now the other part...

typedef quantity<si::length> Length;
Length x = 3.0 * ft;

If x is an SI unit, how can I convert from "ft"?
I'm missing something, but I'm not sure what.

terry


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