|
Boost : |
From: Jeff Garland (jeff_at_[hidden])
Date: 2001-10-31 18:21:27
> This appears to be similar to the upcoming SIunits library.
> You may want to postpone your money<> class until you
> could have had a look at SIunits (not yet available,
> but "really soon" (says Walter Brown)).
I wouldn't wait. You can download Walter's discussion of the tricks used by
SIUnits from here: http://www.oonumerics.org/tmpw01/schedule.html.
> Not that SIunits will solve the money<> problem, but
> it may offer valuable implementation hints and you may
> want to make money<> interoperable with SIunits
> ("dollars per liter").
After seeing Walter's presentation of SIUnits at the Template programming
workshop and discussing this very issue with Walter, I don't think there will be
much benefit to making SIunits interoperate with money<>. The basic reason is
that they are really trying to address totally different domains. The kind of
combinations you want to prevent in the money domain is much different from that
of SIUnits (Walter makes this argument, with a bunch more reasons, far more
elegantly).
I haven't had a chance to look in detail at your these classes, but at a high
level the FixedDecimal looks to be very useful. Based on my brief look, I would
be inclined to drop the money class until it's role could be defined a bit
better than as a way to do I/O (please correct my perception here if I am off
base, b/c I haven't followed the whole thread here). For example, a class that
carries the currency information (eg: US Dollars, Euro, etc) along with the
value might be a useful basis for currency conversion as well as I/O. This
would have a flavor more like SIUnits in that we would want to prevent:
USD mymoney(50); //fifty dollars
Euro yourmoney(100); //100 Euros
mymoney += yourmoney; //oops types not compatible or runtime error
Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk