Boost logo

Boost :

From: David A. Greene (greened_at_[hidden])
Date: 2006-06-13 20:26:05

Janek Kozicki wrote:

> Instead of modifying the source code of the library, just add there
> following macro (macro name can be different of course):
> #define BOOST_UNITS_DIVIDED(numerator,denominator,new_type) \
> typedef /*typename */ pqs::meta::binary_operation< \
> numerator, \
> pqs::meta::divides, \
> denominator \
> >::type new_type \
> (this macro works in boost 1.33 - without boost::typeof. A similar macro
> can be written to utilize boost::typof. Of course a second macro
> BOOST_UNITS_MULTIPLIED would be needed as well)
> This macro allows to define custom units with small trouble - just write
> the unit components. Taking example from my review - I had problems with
> a unit N/m (spring stiffness). With above macro I just write one line:
> BOOST_UNITS_DIVIDED(pqs::force::N,pqs::length::m,N_div_m);
> and now I have a new type named N_div_m and I can use it as desired.

> IMHO adding this macro will increase pqs' library capabilities a lot.

This is interesting and useful. However, it still doesn't solve
the problem of how to define units in a completely different
system than SI. Folks have mention particle physics as one
domain where this is needed. I've talked talked about units
where the prefixes are not powers of 10 (specifically, Mibibytes,
etc.). So this is a good start but it needs to go further.

I'm ok with more work to define such non-SI units but it shouldn't
be any more difficult than someone defining an SI without the
handy macro.

In other words, I think things can be designed with flexibility in
mind and the SI units presented as an implementation on top of
that framework. The SI units becomes a "library" on top of the
"framework." No need to pqs to implement all unit systems. Just
one demonstration with a widely-used system (SI) is enough. Others
can contribute other units libraries as desired.


Boost list run by bdawes at, gregod at, cpdaniel at, john at