
On Jan 12, 2009, at 3:48 PM, Steven Watanabe wrote:
AMDG
Mark Volkmann wrote:
On Jan 9, 2009, at 5:33 PM, Matthias Schabel wrote:
My biggest issue is that my recent software development experience has involved using Java much more than C++ and I'm trying to learn how to use a C++ library that makes pretty heavy use of templates. Is there a tutorial somewhere that shows examples of doing basic things with this library? The kind of things
The examples directory has simple, functional demonstrations of just about every type of functionality that anyone has wanted to date.
Okay, I've looked at the code related to conversions. conversion_factor.cpp sets up a bunch of double values that I assume are used to convert values in one unit to values in another. However, they aren't used in any code.
conversion_factor isn't used for conversions. It just returns the value that would be used for a conversion.
I thought that was the case. However, I haven't yet worked out how to
create a conversion_factor for miles to kilometers. That should be
just a few lines I think. Here's what I tried:
#include
I don't see any example that actually performs a conversion using conversion_factor. Can you show me how to use that to convert miles to kilometers? It looks like kilometers isn't defined in any of the .hpp files. I can just multiply meters by 1000 myself, but if there's something in the library that hides this detail, I'd like to know about it.
http://www.boost.org/doc/html/boost_units/Examples.html#boost_units.Examples... The example uses SI and CGS, but converting between any units is similar.
Thanks. I've read that page several times already and still don't get
it. I suspect my lack of experience with C++ templates is the issue. I
see this:
This example demonstrates the various allowed conversions between
SI and CGS units.
Defining some quantities
quantitysi::length L1 =
quantitysi::length,int(int(2.5)*si::meters);
quantitysi::length,int
L2(quantitysi::length,double(2.5*si::meters));
* explicit casting of a quantity to a different value_type :
quantitysi::length,int L3 =
static_cast
(L1);
However, I don't know what to specify in place of cgs::length in order to use miles instead of centimeters. I wish that page contained an example of converting from some U.S. unit (such as miles) to some SI unit (such as meters). --- Mark Volkmann