Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-06-28 09:21:50


In operators.hpp,
the commutative two-type versions of the operators,
such as addable2 have both versions of the operators defined:

struct addable2 : B
{
     friend T operator+(T x, const U& y) { return x += y; }
     friend T operator+(const U& y, T x) { return x += y; }
};

the non-commutative versions, such as subtractable2

have only one version:

struct subtractable2 : B
{
     friend T operator-(T x, const U& y) { return x -= y; }
};

Shouldn't there be a second version such as

     friend T operator-(const U& x, const T& y)
     {
       T x1(x);
       return x1 -= y;
     }

IMHO, it does not make much sense to provide the
two-type versions of the operators when U is not convertible to T.

Helmut


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