Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-03-28 19:20:24


AMDG

Lewis Hyatt <lhyatt <at> princeton.edu> writes:

>
> -What is your evaluation of the design?
>
>
> I do disagree with previous comments on the evilness of the mutating
> value() method.
>
> <snip>

We were going to replace it with
quantity_reinterpret_cast<T&>(q).
This make the fact that it is dangerous
more obvious in addition to allowing
searches.

> Also, quantity<> should pass through operator++ and operator-- in
> addition to the other arithmetic operators.

Will do.

> <snip>
>
> I was surprised by the following behavior:
>
> #include <iostream>
> #include <boost/units/io.hpp>
> #include <boost/units/systems/si.hpp>
> #include <boost/units/systems/cgs.hpp>
> #include <boost/units/systems/si/prefixes.hpp>
> using namespace boost::units;
>
> int main()
> {
>
> quantity<CGS::force> F0 = 20 * CGS::dyne;
>
> quantity<SI::force> F1 = quantity_cast<SI::force>(F0);
> quantity<SI::force> F2 = quantity_cast<SI::force>(20 * CGS::dyne);
>
> quantity<SI::force> F3(F0);
> //quantity<SI::force> F4 = F0;

This requires a conversion. The construtor is explicit.

>
> //quantity<SI::force> F5(20 * CGS::dyne);

Ouch. I noticed this before but never fixed it.
I'll take care of it immidiately

> //quantity<SI::force> F6 = 20 * CGS::dyne;

Again, the constructor is explicit.

> <snip>
>
> Also problematic is F2, which does compile, albeit with a warning, but
> then does the wrong thing at run time. The output of this program is:
>
> 1e-05 m kg s^(-2)
> 0 m kg s^(-2)
> 1e-05 m kg s^(-2)
>
> This appears to be related to the fact that in the initialization of F0,
> there is an implicit conversion from the int (20) to double.
>
> <snip>

I'll fix it.

> -What is your evaluation of the documentation?
>
> The large number of examples is excellent. The documentation needs a
> lot more substance to it, particularly explaining surprising features of
> implicit conversions.

Better: fix the problems.

> -What is your evaluation of the potential usefulness of the library?
>
> One concern I have, is that I use a lot of C++ wrappers
> over legacy C libraries such as CLAPACK and ATLAS.
>
> <snip>

If you are doing that I would put the
assertion at the point where you cast.

> <snip>

Thank you.

In Christ,
Steven Watanabe


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