Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2000-11-29 17:11:59


"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);
    // ...
  };

(Adjust name to taste.)

By using "rational<T>" as their return value, the global functions
would be already (logically) coupled with the rational class. Thus,
I suggest making them (static) members to make the coupling more
explicit. You could think of these static members as "constructors
with names".

As a side note, the global functions shown above require explicit
function template instantiation, which I found to be buggy with MSVC.

Jens Maurer


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