Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2006-09-06 12:13:30


>>> Other observations:
>>> 1) unit_test_1.cpp depends on the boost.regex library. (Some of us
>>> have
>>> never built the boost.regex library. My solution is just to skip
>>> unit_test_1.cpp for now.)
>>
>> If you don't #define MCS_USE_DEMANGLING, this should not happen now.
>
> I am not #defining MCS_USE_DEMANGLING, but VC++8.0 tries to link to
> the
> boost regex library. Can this be fixed?

Sorry - I should have been more clear; I inserted a #define
MCS_USE_DEMANGLING in unit_test_1.cpp. If you comment it out, that
should eliminate the boost::regex dependency... N.B. if you look too
closely at this example, there are a couple of errors - not in the
code, but in the type definitions...missing a minus sign in the time
dimension of energy...I'll have them fixed in the next release, which
will also eliminate the demangling option unless you're using g++.

Also, for the next release I'll have a version that allows arbitrary
binary operations between quantities (limited, of course, by the
operations supported by the underlying value_type) that deduces
return type using typeof. That is, for some arbitrary value types X
and Y for which (warning pseudocode ahead)

Z operator+(X x,Y y)

is defined

quantity<Z> operator+(quantity<X> x,quantity<Y> y)

will work and behave as expected... Currently this feature will only
work on gcc or other compilers that have already implemented typeof,
but I'm hoping that it will just be ignored on other platforms as
long as the code doesn't actually call operators with two different
types, assuming I've written the type conversion helpers right...
Eventually I'll look into Boost.Typeof, if there's enough interest.
For the most part, this feature is probably just a curiosity for the
average programmer, but it's a good test and allows more interesting
algebras to be associated with units...my demo code (mostly
functional except for power<N>/root<N>) is for a scaled value type
(something like Andy Little does internally) that carries with the
value type a base/exponent pair, so you could write values in
scientific notation like this :

5.67 x 10^7 -> scaled_value<float,scale<10,7> >(5.67) svalue;

Here, if you multiply this by itself, you get a new type:

svalue*svalue -> scaled_value<float,scale<10,14> >(5.67*5.67)

It's amusing and might actually be useful...

>>> 2) The unit tests appear to build using gcc 3.4.4, but not with
>>> VC8.0.
>
> The latest version of the examples builds and runs with VC8.0 (except
> unit_example_1, because I have not tried to build the boost regex
> library).

That's good news - I don't have a Windows box, so I can't check this
myself...

> In many ways your library looks nice, but I need to check out Ben's
> more
> carefully too.

Thanks. In all honesty, I would be happy to collaborate on this with
others who are interested and have a compatible paradigm - I don't
really have much experience dealing with issues such as IO facets,
etc..., and there are a number of issues surrounding IO and
serialization that probably need to be thought about and addressed.
Obviously, because units are defined at compile time input will be
restricted to cases where the type is known anyway, so it doesn't
seem like there's really much point in parsing unit input (for this
library - clearly, a runtime units library would want to do that...).

Anyway, I appreciate the feedback...

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk