Boost logo

Boost Users :

Subject: [Boost-users] boost::units question
From: Mario Charest (stayprivate_at_[hidden])
Date: 2012-03-09 13:23:20


I have been reading the doc and writing small program to learn about
boost::units. Incredible tool !!!

My question is one of proper programming, as I am not sure I fully
understood the intricacy of boost::units. What I would like to acheive is
a unit of thou, inch, feet. Then I want to be able to copy from variable
to variable and have everything converted automatically

myunit:thou aaa(50000*thou)
myunit:inch bbb(50000*thou);
myunit:feet ccc(50000*thou);

myunit:thou ddd(50*inch);
myunit:inch eee(50*inch);
myunit:feet fff(50*inch);

// and then

std::cout << aaa << std::endl;

ccc = static_cast<myunit::feed>(aaa);
.. and all various variation

I came very close to getting this to work, just had some issue with the
names and symbols showd by the inch and feed unit has they would be
displayed in kthou (because of scalling I guess) ;-)

I read the doc many times but couldn't really grasp how to deal with scaled
units, how they fit with based_units and units?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at