Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2004-01-08 18:04:01


Jan Langer wrote:
>
> the problem is not the assignment, but the other operators. for example
> addition, what is correct the first or the last form?
>
> template <typename Unit1, typename Unit2>
> Unit1 operator + (Unit1 u1, Unit2 u2)
> {
> Unit1 t;
> convert (t, u2);
> return u1 + t;
> }
>
> template <typename Unit1, typename Unit2>
> Unit2 operator + (Unit1 u1, Unit2 u2)
> {
> Unit2 t;
> convert (t, u1);
> return t + u2;
> }
>

The point is to allow neither and force an explicit conversion,
before doing the operation.
> jan
>


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