From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-08-30 02:16:34
Some questions about the new text:
> Another application of the two-argument template forms is for mixed
> arithmetics of a type T and a type U convertible to T. In principal, the
> compiler could use the single type binary operator and just convert the type U
> argument to type T. In practice, however, there are often more efficient
> implementations of, say T::operator-=(const U&) that avoid unnecessary
> conversions from U to T. The two-argument template forms of the arithmetic
> operator create the additional operator interfaces. For the mixed type of
> non-commutative operators where U appears on the left hand side
> (operator-=(const U&, const T&), operator/=(const U&, const T&),
> operator%=(const U&, const T&)) 'left' forms of the two-argument template
> forms (subtractable2_left<T,U>, dividable2_left<T,U>, modable2_left<T,U>) are
> provided. Their implementation uses a conversions from U to T and is
> equivalent to the code that would be automatically created by a compiler if it
> found a suitable overload.
What's the point, then? You started out saying that it was desirable to avoid
conversions from U to T... I think the text needs to be clearer here.
> These signatures, however, are provided for
> symmetry reasons and to prevent potential conflicts with other equally well
> matching operator signatures.
I think some clarification is needed here also.
I really like the new grouped operator templates. It's nice to add a little more
"theoretical foundation" here.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk