Boost logo

Boost :

From: Chris Frey (cdfrey_at_[hidden])
Date: 2005-06-20 16:01:23


Hi,

I recently had a need to investigate money classes. I searched for
such a beast, since I was sure I wasn't the first to have a need for this,
but it was only after I had coded up a good chunk of my own implementation
that I came across a boost mailing list thread involving
Martin <adrianm_at_...> and Daniel Frey:

        http://lists.boost.org/MailArchives/boost/msg77625.php

Martin gives a link to his decimal classes here:

        http://web.telia.com/~u84606172/Boost/

In boostdecimal.zip's boost/decimal/money.hpp, I find the following code:

---- snip -------------------------------------------------------
# define BOOST_MONEY_OPERATOR(op, type) \
  template <class DecimalT> \
  inline money_base<DecimalT> operator##op(money_base<DecimalT> l, type r) { return l op= r; } \
  template <class DecimalT> \
  inline money_base<DecimalT> operator##op(type l, money_base<DecimalT> r) { return r op= l; }

  BOOST_MONEY_OPERATOR(+, int)
  BOOST_MONEY_OPERATOR(-, int)
  BOOST_MONEY_OPERATOR(*, int)
  BOOST_MONEY_OPERATOR(/, int)
---- snip -------------------------------------------------------

As far as I can see, the second item in the BOOST_MONEY_OPERATOR macro is
incorrect. Consider:

        money m = 2;
        5 - money(2);

This would result in:

        money(2) -= 5;

I'm happy to see some interest in money classes on the boost lists.
Is this project still being pursued?

Thanks,
- Chris


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