Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-01-19 14:33:06

Hi Janek,

> I want to thank you very much for your effort. My time currently is
> very limited, so I had a chance for a very short glance at your
> examples. And I liked very much what I've seen.

Thanks for the encouragement - I'm actually on vacation right now (as
embarrassing as that is to admit), so I've had some time to devote to
getting things shaped up... I certainly appreciate the feedback - please
keep it coming as you find time to look at the library in more detail...

> I recalled another common request: some people wanted to add currency
> and unit conversions between various currencies (using a multiplier
> that can change during the program run). I work in engineering so
> it's not for me. But for those people who need it, will it be
> possible?

I recall the same; my opinion is that the full dimensional analysis
is probably overkill for this kind of application as I have a hard
time envisioning
units like $ m/s^2 being useful, but it should be possible, again, by
currencies as
value types...something like this:

// currency unit systems
struct currency_system { };

struct currency_tag : public ordinal<1> { };

typedef dimension< boost::mpl::list< dim<
currency_tag,static_rational<1> > > >::type currency_type;

typedef unit<currency_system,currency_type> currency;

class us_dollar
{ ... };

class canadian_dollar
{ ... };

quantity<currency,us_dollar> usd(us_dollar(date1));
quantity<currency,canadian_dollar> cd(canadian_dollar(date2));

This way the value_type takes care of all the conversions (say to and
from constant US dollars fixed
at a certain date or however you like) and all the units library does
is keep track of the fact that the
quantity is a currency. By doing this, everything is completely
decoupled. If implicit conversion of
currencies is supported, this is transparent through quantity...


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