Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-01-12 16:36:51

Stephen Silver wrote:
> > For the problem at hand, it seems sufficient to have a rational
> > constructor which takes an "int" (or long) only.
> But then someone will use a value that doesn't fit in a long (e.g., an
> unsigned long, or a larger non-standard type) and it will be converted
> to an int (or a long), with the wrong result.

Then we need two overloads: One for "long" and one for "unsigned long".
Or, if you want to play really safe, use boost::intmax_t and boost::uintmax_t
from <boost/cstdint.hpp>.

> I think all types that
> are implicitly convertible to IntType ought to be implicitly convertible
> to rational<IntType> as a matter of principle, and a template is the
> only way to do that.

I would feel much better if we could postpone the implementation of
the template constructor until someone shows up who demonstrates a
real-life need for it.

Jens Maurer

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