|
Boost : |
From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-11-30 14:11:06
In message <3A257F2F.BD897CAE_at_[hidden]>, Jens Maurer
<Jens.Maurer_at_[hidden]> writes
>"Moore, Paul" wrote:
>> With that, I'll add two functions,
>> tentatively named rationalize_exact() and rationalize_simplest(), based on
>> the two cases we have seen.
>
>I understand this to mean:
>
> template<class T>
> rational<T> rationalize_exact(double x);
>
>As a minor syntax issue, I would like to suggest static member
>functions instead of global ones, for example
>
> template<class T>
> class rational {
> public:
> static rational exact_from_double(double x);
> // ...
> };
I think I would prefer to follow the lead of the STL and keep these
separate. These are two of many possible algorithms, and I'm sure others
could be added by users, included dreaded parsers from strings. As the
set of conversions seem to be extensible and highly parameterisable,
leaving them outside the class seems to give the strongest hint that the
rational class template itself is independent of them.
Kevlin
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
Curbralan Limited mobile: +44 7801 073 508
mailto:kevlin_at_[hidden] fax: +44 870 052 2289
http://www.curbralan.com
____________________________________________________________
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk