Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-01-02 18:32:09


I've got to my implementation of scaling operators in 'delta' and 'point',
and I just realized how stupid I was when I wrote these:

template<class T>
class delta
{
  public:
    typedef T unit_type;
...
    self& operator *=( unit_type scale );
    self& operator /=( unit_type scale );
    self& operator *=( const delta<unit_type>& scale );
    self& operator /=( const delta<unit_type>& scale );
...
};

First, the scaling factor ('scale' argument) has nothing to do with
'unit_type' - if unit_type == int, we still may want to scale our figures
with an arbitrary factor, e.g. 1.5. Second, versions of operator *= and
operator /= with 'const delta<unit_type>&' parameters are completely
non-sense - by the same reason. Probably they must take something like
'const pair<double, double>&', but I have a big doubts about it. Is it
acceptable to have 'double' type hardcoded in this manner to the interface
of 'delta' and 'point'? I wish to use member function templates, but this is
unrealistic by now and, I'm afraid, will be so for a long time. Any
thoughts?


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